![]() Princeton University |
Computer Science 111 |
|
OS defines machine more than hardware does =>
Gives abstractions for use
Still translate programs to machine code,
but all use of computer resources done through OS
OS has privileges other programs don't
What needs to be managed?
CPU
Memory
Peripherals
CPU and memory in early simple systems not problem
Peripherals: device drivers
Programs w/in OS that know details of how to communicate with each device
Different kinds, makes, ...
Other prog.s make "system call"
Disk special: File system organizes
Programs/users don't need to know where on disk
naming convention
BIG abstraction:
sectors/tracks => file names
most file systems tree-structured
User interface ("shell")
When log on, "talking" to OS
Can start other programs
"applications"
User interfaces have different styles
Compare:
Microsoft Windows family:
Mouse-based, graphical
Icons and menus
UNIX:
Keyboard-based, textual
Type commands
(e.g. "ls" "cd")
Add SHARING
"time sharing" "multitasking"
=> CPU and memory management no longer easy
doing more than one thing "at once"
many tasks for one user, or many users
"thing" called process
a running program
(script of play vs performance of play)
Once have sharing, new issues:
Fairness each process gets to run and gets resources
Protection processes don't damage each others programs or data
How several processes run "at once"?
OS gives each little "slice" of time on CPU => managing CPU
OS gives each own section of memory => managing memory
Managing CPU OS scheduler
How get slices of time?
each process gets so much
2) Use input/output waiting:
when process stops to wait for data from a peripheral device (I/O), its turn is over
scheduler maintains a table processes
A process can be:
When process stops, OS records:
Program Counter (PC)
Values in registers
Location of its section of memory
Scheduler remembers status and priority of each process that has started but not finished
Scheduler chooses from ready processes one of highest priority to run next
Priorities must be managed so get fair access to CPU
Processes are stopped
by interrupts Signals from I/O devices or timer to CPU
Or by service calls in program requesting service from OS
Interrupts are hardware signals,
Act like "jump" instructions, but save old PC
Send CPU to special program that "handles" interrupts
Action of special program depends on type of interrupt
Examples:
Timer interrupt:scheduler stops process that was running and gives new one a turnone process goes from "running" to "ready" and one from "ready" to "running"
Peripheral "done" signal: scheduler moves waiting process to "ready" and chooses some "ready" process to run
Error: special error handlers; action depends on error.
OS memory manager sharing
Create illusion (abstraction) that each process has all memory wants
Memory manager keeps tables:
virtual memory what process thinks has
versus
physical memory actual hardware where bits stored
security: no process can write to memory "owned" by another process
Push illusion farther ...
Size of virtual memory much greater than Size of physical memory
How?
Term: paged virtual memory
Technique used by OS:
Each process owns group of pages
Pages may be really stored on disk or in physical memory
When CPU needs to Load or Store from/to a page actually on disk (not in physical memory):
Can usually keep pages being used by running process in physical memory for whole of time slice
Peripherals what effect sharing?
I. Shared file system
Protections user says who can read or write (e.g. "everyone", "just me")
2 "approved" accesses at once? OS may allow (e.g. writing to same file at same time in Unix)
Can extend to shared file system over network (e.g. your CIT acct folder access from any machine on network)
OS has mechanism for network connection
standard protocals => can access from different OS's
II. Sharing other peripherals
Need temporary exclusive access (e.g. printer)
Spooling
Spooling gives user illusion done printing when only written to disk (faster).
Fairness in first come/first served
Operating System components discussed:
Lots of hidden detail
Hardware support for OS: special machine instructions