Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza ...
Transcript of Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza ...
![Page 1: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/1.jpg)
Process ManagementProcess Concepts
Frédéric Haziza <[email protected]>
Department of Computer Systems
Uppsala University
Spring 2008
![Page 2: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/2.jpg)
Introduction Process Scheduling Comm. Threads
Outline
1 Introduction
2 OSKomp’08 | Process Management (Process Concepts)
![Page 3: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/3.jpg)
Introduction Process Scheduling Comm. Threads
Recall
Process Management
Memory Management
Storage Management
Protection and SecurityNot in
the class: Networking, GUI, Device Drivers
3 OSKomp’08 | Process Management (Process Concepts)
![Page 4: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/4.jpg)
Introduction Process Scheduling Comm. Threads
Hardware
CPU MEM Disk
4 OSKomp’08 | Process Management (Process Concepts)
![Page 5: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/5.jpg)
Introduction Process Scheduling Comm. Threads
Structuring an Operating System
Monolithic
Layered
Microkernel
Modular
(MS-DOS, Original Unix)
(Unix)
(Mach)
(Solaris)
5 OSKomp’08 | Process Management (Process Concepts)
![Page 6: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/6.jpg)
Introduction Process Scheduling Comm. Threads
Not so much structure
Most functionality in the least space.
6 OSKomp’08 | Process Management (Process Concepts)
![Page 7: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/7.jpg)
Introduction Process Scheduling Comm. Threads
Layered Approach
7 OSKomp’08 | Process Management (Process Concepts)
![Page 8: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/8.jpg)
Introduction Process Scheduling Comm. Threads
Microkernel
8 OSKomp’08 | Process Management (Process Concepts)
![Page 9: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/9.jpg)
Introduction Process Scheduling Comm. Threads
Modular Approach
9 OSKomp’08 | Process Management (Process Concepts)
![Page 10: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/10.jpg)
Introduction Process Scheduling Comm. Threads
User vs Kernel Mode: Hardware protection
10 OSKomp’08 | Process Management (Process Concepts)
![Page 11: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/11.jpg)
Introduction Process Scheduling Comm. Threads
System Boot
Small piece of code - bootstrap loader• locates the kernel,• loads it into memory,• and starts it
Sometimes two-step process where boot block at fixedlocation loads bootstrap loaderWhen power initialized on system,
• execution starts at a fixed memory location• Firmware used to hold initial boot code
11 OSKomp’08 | Process Management (Process Concepts)
![Page 12: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/12.jpg)
Introduction Process Scheduling Comm. Threads
Outline
1 Introduction
2 Process
3 Scheduling
4 Communication
5 Threads
12 OSKomp’08 | Process Management (Process Concepts)
![Page 13: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/13.jpg)
Introduction Process Scheduling Comm. Threads
What characterizes a process?
Program in execution
Stack (Temporary data, function parameters,...)
Heap
Data section (Global variables)
CPU Registers
Program Counter (PC)
Program code = Text section
Program in execution = text section (executable file) loaded inmemory
Process in Memory: See black board
13 OSKomp’08 | Process Management (Process Concepts)
![Page 14: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/14.jpg)
Introduction Process Scheduling Comm. Threads
States
New The process is being created
Running Instructions are being executed
Waiting for some event to occur (I/O completion, signal...)
Ready Waiting to be assigned to a processor
Terminated Finished its execution
14 OSKomp’08 | Process Management (Process Concepts)
![Page 15: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/15.jpg)
Introduction Process Scheduling Comm. Threads
States
15 OSKomp’08 | Process Management (Process Concepts)
![Page 16: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/16.jpg)
Introduction Process Scheduling Comm. Threads
Process Control Block (PCB)
PCB
process stateprocess ID (number)
PCRegisters
memory informationopen files
other resources
16 OSKomp’08 | Process Management (Process Concepts)
![Page 17: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/17.jpg)
Introduction Process Scheduling Comm. Threads
How is in control?
Interrupts• Generated asynchronously by external devices and timers• Example: The I/O is complete or timers have expired
Traps (software errors, illegal instructions)
System calls
17 OSKomp’08 | Process Management (Process Concepts)
![Page 18: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/18.jpg)
Introduction Process Scheduling Comm. Threads
What happens at a transition?
18 OSKomp’08 | Process Management (Process Concepts)
![Page 19: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/19.jpg)
Introduction Process Scheduling Comm. Threads
Scheduling Queues
Job QueueLinked list of PCBs
(main) job queue
ready queue
device queues
19 OSKomp’08 | Process Management (Process Concepts)
![Page 20: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/20.jpg)
Introduction Process Scheduling Comm. Threads
Scheduling
Job scheduler (loads from disk)
CPU scheduler (dispatches from ready queue)
20 OSKomp’08 | Process Management (Process Concepts)
![Page 21: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/21.jpg)
Introduction Process Scheduling Comm. Threads
Context Switch
Context switchPCB swap
Cost?
10ms switch for 100ms work => 9% wasted
21 OSKomp’08 | Process Management (Process Concepts)
![Page 22: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/22.jpg)
Introduction Process Scheduling Comm. Threads
Process creation and termination
See the lab 1 ...
22 OSKomp’08 | Process Management (Process Concepts)
![Page 23: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/23.jpg)
Introduction Process Scheduling Comm. Threads
Interprocess Communication (IPC)
2 modelsMessage Passing
Shared Memory
See black board...
BenefitsSmall amount to exchange=> Message Passing, because no conflict to avoid
Shared Memory=>Working at the speed of memory – faster
23 OSKomp’08 | Process Management (Process Concepts)
![Page 24: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/24.jpg)
Introduction Process Scheduling Comm. Threads
Shared Memory
Recall that the OS prevents processes to share memory⇒ Agreement on relaxing restriction
Example (Producer-Consumer)Unbounded buffer and bounded buffer (book p98)
Producer Consumer
Shared Resource
24 OSKomp’08 | Process Management (Process Concepts)
![Page 25: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/25.jpg)
Introduction Process Scheduling Comm. Threads
Shared Memory
Producer Consumer
Shared Resource
Requires:
Synchronisation(No consumption of non produced items)Waiting
25 OSKomp’08 | Process Management (Process Concepts)
![Page 26: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/26.jpg)
Introduction Process Scheduling Comm. Threads
Message Passing
No shared space.Can be distributed accross network
ExampleChat program
send(m)
receive(m)
Requires a communication link
direct or indirect (mailbox/ports)
synch. or asynch. (blocking or non-blocking)
automatic or explicit buffering (info on the link)
26 OSKomp’08 | Process Management (Process Concepts)
![Page 27: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/27.jpg)
Introduction Process Scheduling Comm. Threads
Threads
Heavy-weight vs Light-weight...
Example (Web server)We want to serve more than one client at a time
1 process. If incoming request, new process created => costly!
1 process. If same task as other one, why overhead => better to multithread
On Solaris:
Time for creating a process = 30 x time for creating a thread
Time for context switching = 5 x time for switching a thread
27 OSKomp’08 | Process Management (Process Concepts)
![Page 28: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/28.jpg)
Introduction Process Scheduling Comm. Threads
Benefits
Responsiveness
Resource sharing
Economy
Utilization of multiprocessor architectures
28 OSKomp’08 | Process Management (Process Concepts)
![Page 29: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/29.jpg)
Introduction Process Scheduling Comm. Threads
Multithread Models
Deals with correspondance between
threads in user space
threads in kernel space
One to One Many to One Many to Many
29 OSKomp’08 | Process Management (Process Concepts)
![Page 30: Process Management - Process Concepts · Process Management Process Concepts Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e81b181a872bf4547104297/html5/thumbnails/30.jpg)
Introduction Process Scheduling Comm. Threads
Issues
fork() creates a copy of a process with all threadsorjust the one which calls the fork?
Cancellation
Signal handling: Read in book page 139
Thread pool (limit in system, pre-create threads)
Thread specific data (sharing data?)
about the models themselves
30 OSKomp’08 | Process Management (Process Concepts)