Terminal Cycle
Terminal Cycle
University of Pennsylvania
Fall 2003
Lecture Note 1: Introduction
1
What is an Operating System?
2
Resource Abstraction and Sharing
q It is a resource manager
ß Time on CPU is shared among multiple users/programs
ß Space in memory and on disks is shared among multiple
users/programs
3
Pentium Architecture
4
Abstractions in OS
Hardware OS abstraction
q Disks q Files
q Memory q Programs
q Processors q Threads / Processes
q Network q Communication
q Monitor q Windows and GUI
q Keyboard q Input
q Mouse q Locator
5
Sharing of Memory
Issues
q Allocation schemes
Program 1
q Protection from each other
Free space q Protecting OS code
6
Timesharing
P1 OS P2 OS P1 OS P3 OS
q OS must do all the book-keeping necessary for context switch, with minimum number
of instructions
7
Challenges in OS
Why can’t Microsoft still get rid of all bugs in Windows ?
q Performance is critical
q Memory management
9
Inside a CPU
q State of a running program
ß Registers
ß Program counter (PC)
ß Stack pointer
ß Program status word (PSW)
q Key distinction in PSW: user mode vs kernel (OS) mode
q Key instruction for OS calls: TRAP (switch to kernel mode)
q Many operations (such as accessing I/O devices) are possible only in
the kernel mode
10
Different types of Memory
q Hardware saves the state of current program, sets the mode-bit in PSW
register in CPU to 1, and transfers control to a fixed location in OS code
q OS maintains an internal file table that stores relevant information about all
open files
12
Sample Scenario 1 (continued)
q OS read routine examines the parameters, checks for errors (e.g. file must
be open), consults its file table, and determines the disk address from
where data is to be retrieved
q When OS routine finishes the job, it stores the status code, and returns
control to the user program P (hardware resets mode-bit)
q Compiler assigns logical addresses, say Add1 and Add2, for program
variables in P’s data space
q OS maintains an internal table, called page table, that keeps track of which blocks
of P are in memory
q If Add1 is not in memory, MMU generates a page fault, and transfers control to OS
q OS examines the cause, and initiates a disk transfer to load in the relevant block of
P
q While this block is being fetched, P may be suspended using a context switch
15
Brief History of Operating Systems
16
1940's -- First Computers
17
1950's -- Batch Processing
18
Typical Batch System
19
1960's -- Multiprogramming
(timesharing)
q The advent of the I/O processor made simultaneous I/O and CPU processing
possible.
q CPU is multiplexed (shared) among a number of jobs -- while one job waiting for
I/O, another can use CPU.
q Advantages:
ß Interactiveness is restored.
ß CPU is kept busy.
q Disadvantages:
ß Hardware and O.S. required become significantly more complex.
q Timesharing - switch CPU among jobs for pre-defined time interval
q Most O.S. issues arise from trying to support multiprogramming -- CPU scheduling,
deadlock, protection, memory management, virtual memory, etc.
q CTSS (Compatible Time Sharing System), Multics
20
1970's - Minicomputers &
Microprocessors
22
1990's and Beyond
q Monolithic Systems
q Layered Systems
q Virtual Machines
q Client-Server Model
24
Operating System Structure (1)
25
Operating System Structure (2)
27
Operating System Structure (4)
28
Operating System Structure (5)
29