Users Run Many Applications Simultaneously: Expect All To Be Running, Doing Work For You
Users Run Many Applications Simultaneously: Expect All To Be Running, Doing Work For You
UNIVERSITY of WISCONSIN-MADISON
Computer Sciences Department
Users Run Many Applications
CS 202 Professor Andrea Arpaci-Dusseau Simultaneously
Introduction to Computation Fall 2010
Lecture 25:
How does a computer…
"
run many applications simultaneously?
1
11/1/10
2
11/1/10
Challenges with
How to Share Memory?
Sharing Memory
Illusion provided by Operating System?
• Each process has all of physical memory to itself
1) Ensure one process cannot r/w another process’s
memory
Reality: Reside in physical memory at same time
• OS and HW cooperate to implement protection
Technique: Space sharing – Translate memory references from logical to physical addresses
Physical View
Physical View
Process 1 Process 1
Process 3 Process 3
Process 2 Process 2
Logical View of Address Space Logical View of Address Space
Everything process can address thru memory including data and code Everything process can address thru memory including data and code
3
11/1/10
Challenges with
How to Share CPU?
Sharing Memory
2) Not enough physical memory for all address spaces Process alternates btwn CPU and I/O
• What policy should OS use to determine what • I/O: wait for user input
is kept in memory and what is not? • Analogy: Alternate btwn bathroom and bedroom
Time sharing: Switch quickly between processes
Physical View
OS and HW together perform context switch
• Change contents of registers and Program Counter (PC)
– Stored in memory when not running (only OS can read this memory)
• Change active address space in memory
Process 1 – One process should not be able to read data of another process!
Example:
How to Share CPU?
Service at a Deli
If only one wants CPU, no problem Many customers waiting for service at deli…
In what order should customers be handled?
What do you do if multiple processes want CPU at
same time?
4
11/1/10
5
11/1/10
6
11/1/10
7