Date post: | 28-Dec-2015 |
Category: |
Documents |
Upload: | merryl-riley |
View: | 221 times |
Download: | 2 times |
CS 423 - Fall 2011
CS 423 – Operating Systems Design
Lecture 2 – Concepts Review
Klara Nahrstedt
Fall 2011
CS 423 - Fall 2011
Overview
Administrative Issues System Concepts Review (cs231, cs232,
cs241) Read Tanenbaum textbook
Chapter Sections: 1.4-1.6
CS 423 - Fall 2011
Administrative Issues
MPs Find MP partner (s) and submit form from compass
about the groups today 8/24 MP1 will be posted on Monday 8/29 (not graded, but
very strongly recommended) Proficiency Exam
Student will do MP4 and final exam Student needs to get VMware server account and
should contact TAs to arrange for the environment ahead of MP4 posting time
Review cs231/232/241 concepts
CS 423 - Fall 2011
Typical Computer System
Operating System Software
Programs and data
MemoryCPU
CPU
...
OSApps
Data
Network
CS 423 - Fall 2011
OS Major Components Resource management
CPU Process and Thread Management
Memory Memory Management
Device I/O Management (Disk, Network, Camera, Microphone, Timers,
Power)
File system Bootstrapping
CS 423 - Fall 2011
Processors Each CPU has a specific set of instructions All CPUs contain
General registers inside to hold key variables and temporary results
Special registers visible to the programmer Program counter contains the memory address of the next
instruction to be fetched Stack pointer points to the top of the current stack in memory PSW (Program Status Word) contains the condition code bits
which are set by comparison instructions, the CPU priority, the mode (user or kernel) and various other control bits.
CS 423 - Fall 2011
How Processors Work Execute instructions
CPU cycles Fetch (from mem) decode execute Program counter (PC)
When is PC changed?
Pipeline: fetch n+2 while decode n+1 while execute n
Two modes of CPU (why?) User mode (a subset of instructions) Privileged mode (all instruction)
Trap (special instruction)
CS 423 - Fall 2011
Processor (CPU) Management
Goals Time sharing Multiple CPU allocations
Issues Do not waste CPU resources Synchronization and mutual
exclusion Fairness Deadlock free
Analogy: Video Games
CS 423 - Fall 2011
Memory Access Memory read:
Assert address on address lines Wait till data appear on data line Much slower than CPU!
How many memory access for one instruction? Fetch instruction Fetch operand (0, 1 or 2) Write results (0 or 1)
How to speed up instruction execution?
CS 423 - Fall 2011
CPU Cache
Cache hit: no need to access memory
Cache miss: data obtained from memory, possibly update cache
Source: http://en.wikipedia.org/wiki/Computer_data_storage#Primary_storage
Magnetic Tape400-800 GB100 sec access time
Magnetic Disk200-1000 GB10 msec access time
Registers< 1KB capacity1 nsec access time
Cache4 MB capacity2 nsec access time
Main Memory512-2048 MB10 nsec access time
CS 423 - Fall 2011
Memory Management
How to protect programs from each other? How to handle relocation ? Base register Limit register Check and Mapping of Addresses
Virtual Address - Physical Address Memory Management Unit (MMU – located on CPU
chip or close to it Performance effects on memory system
Cache Context switch
CS 423 - Fall 2011
Memory Management
Goals Support programs to run Allocation and management Transfers from and to
secondary storage Issues
Efficiency & convenience Fairness Protection Tape 100Mx
Disk 10Mx
Memory 200x
L2 10x
Register
CS 423 - Fall 2011
I/O Device Management
Goals Interactions between
devices and applications Ability to plug in new
devices
Issues Efficiency Fairness Protection and sharing
User 1 User n. . .
Library support
I/Odevice
I/Odevice. . .
Driver Driver
CS 423 - Fall 2011
I/O Devices Controller
Example: Disk Controller Controllers are complex converting OS request into
device parameters Controllers often contain small embedded computers
Device Fairly simple interfaces and standardized IDE (Integrated Drive Electronics) – standard disk
type on Pentiums and other computers
CS 423 - Fall 2011
I/O Devices
Device DriverNeeded since each type of controller may be
different. Software that talks to a controller, giving it
comments and accepting responsesEach controller manufacturer supplies a driver
for each OS it supports (e.g., drivers for Windows 7, UNIX)
CS 423 - Fall 2011
File System
A typical file system
Open a file with authentication
Read/write data in files Close a file
Can the services be moved to user level?
User 1 User n. . .
File system services
File File. . .
CS 423 - Fall 2011
Bootstrapping
Power up a computer Processor reset
Set to known state Jump to ROM code
Load in the boot loader from stable storage
Jump to the boot loader Load the rest of the
operating system Initialize and run
Bootloader
OSsector 1
OSsector 2
OSsector n
.
.
.
Bootloader
CS 423 - Fall 2011
From Lecture 1: What is OS Code that:
Sits between programs & hardwareSits between different programsSits betweens different users
Job of OS:Manage hardware resources
Allocation, protection, reclamation, virtualization
Provide services to app. How? -- System Call Abstraction, simplification, standardization
Application
OS
Hardware
CS 423 - Fall 2011
A peek into Unix/Linux
Application
Portable OS Layer
Libraries
Machine-dependent layer
User space/level
Kernel space/level
• User/kernel modes are supported by hardware
•Some systems do not have clear user-kernel boundary
CS 423 - Fall 2011
Unix: Application
Application (E.g., emacs)
Portable OS Layer
Libraries
Machine-dependent layer
Written by programmerCompiled by programmerUses function calls
CS 423 - Fall 2011
Unix: Libraries
Application
Portable OS Layer
Libraries (e.g., stdio.h)
Machine-dependent layer
Provided pre-compiledDefined in headersInput to linker (compiler)Invoked like functionsMay be “resolved” when
program is loaded
CS 423 - Fall 2011
Typical Unix OS Structure
Application
Portable OS Layer
Libraries
Machine-dependent layer
system calls (read, open..)All “high-level” code
CS 423 - Fall 2011
Typical Unix OS Structure
Application
Portable OS Layer
Libraries
Machine-dependent layer
BootstrapSystem initializationInterrupt and exception I/O device driverMemory managementKernel/user mode
switchingProcessor management
CS 423 - Fall 2011
System Calls (POSIX)
System calls for process management Example of fork used in simplified shell program
#define TRUE 1 while(TRUE) {
type_prompt();read_command(command, parameters);if (fork()!=0) {
/* some code*/waitpid(-1,&status, 0);}
else {/* some code*/execve(command, parameters,0);
} }
CS 423 - Fall 2011
System Calls (POSIX)
System calls for file/directory management fd=open(file,how,….)n=wride(fd,buffer,nbytes)s=rmdir(name)
Miscellaneouss=kill(pid,signal)s=chmod(name,mode)
CS 423 - Fall 2011
System Calls (Windows Win32 API)
Process Management CreateProcess- new process (combined work of fork
and execve in UNIX) In Windows – no process hierarchy, event concept
implemented WaitForSingleObject – wait for an event (can wait for
process to exit) File Management
CreateFile, CloseHandle, CreateDirectory, … Windows does not have signals, links to files, …, but
has a large number of system calls for managing GUI
CS 423 - Fall 2011
OS Service Examples Services that need to be provided at kernel level
System calls: file open, close, read and write Control the CPU so that users won’t stuck by running
while ( 1 ) ; Protection:
Keep user programs from crashing OS Keep user programs from crashing each other
Services that can be provided at user level Read time of the day
CS 423 - Fall 2011
You Live in Interesting Times… Processors speed used to double in 18 months
(Moore’s Law), but we are reaching the upper bound (due to thermal problems) and need to go towards multi-core processors, i.e., parallelism to increase the processing power
Disk doubling every 12 months Global bandwidth every 6 month What will the future OS be?