Download presentation
Presentation is loading. Please wait.
1
1 An Architectural View of an OS Inter-process communication Process Scheduling Process Control Subsystem File Subsystem Device Drivers Hardware Control System Call Interface Hardware level Hardware Kernel level User programsLibraries User level Memory Mgt Subsystem
2
2 System Call System call –A set of functions/procedures to interface user-level programs and the underlying kernel –Used to create, use and delete objects in a kernel. e.g., Processes –fork(), exit(), kill(), etc. Files –create(), open(), close(), write(), read(), mkdir(), chmod(), etc. Memory space Network connections
3
3 Process State Transition Process Scheduler ABC ….. A BC t process A B C Program counter (hardware register) Main Memory Layout Process Scheduler 0 x a Process A Process B Process C b c
4
4 Main Memory Process Scheduler 0 x a Process A Process B Process C b c a+0 a+1 a+2 a+N-1 …… A program consisting of N instructions in an assembly language Running an process = Executing a program on a CPU = Executing a sequence of assembly language instructions on a CPU
5
5 Main Memory Process Scheduler 0 x a Process A Process B Process C b c 1a+0 2a+1 3a+2 4a+3 5a+4 6x+0 7x+1 8b+0 9b+1 10b+2 11x+0 12x+1 13c+0 14c+1 15c+2 16c+3 17c+4 18x+0 19x+1 Time out Running A I/O request Running B Process switching Time out Running C CPU TInstructions executed on a CPU x+0 x+1 a+0 a+1 … b+0 b+1 … c+0 c+1 …
6
6 tABC 1 – 5RunningReady 6 – 7Ready 8 – 10ReadyRunningReady 11 – 12ReadyBlockedReady 13 – 17ReadyBlockedRunning 18 – 19ReadyBlockedReady 20 – 24RunningBlockedReady 25 – 26ReadyBlockedReady 27 – 31ReadyBlockedRunning 1a+0 2a+1 3a+2 4a+3 5a+4 6x+0 7x+1 8b+0 9b+1 10b+2 11x+0 12x+1 13c+0 14c+1 15c+2 16c+3 17c+4 18x+0 19x+1 Time out Running A Process switching I/O request Running B Process switching Time out Running C Process switching
7
7 How to Implement Process States? NewReadyRunningTerminated Waiting (Blocked) admitted Dispatched to a CPU interrupted I/O or event wait I/O or event completion exit
8
8 CPU NewReadyRunningTerminated Waiting (Blocked) admitted Dispatched to a CPU interrupted I/O or event wait I/O or event completion exit Ready Queue admitted dispatched exit interrupted I/O or event wait I/O or event completion Blocked Queue
9
9 Memory Layout and Memory Program Counter Main Memory Layout Process Scheduler 0 x a Process A Process B Process C b c a+0 a+1 a+2 a+N-1 …… A program consisting of N instructions in an assembly language Assumption: All processes exit in the main memory. What if the total size of processes exceeds main memory’s size?
10
10 Process Swapping Process swapping –Moving a part or all of a process from main memory to disk. Virtual memory Who to be swapped out from main memory? –Blocked processes They cannot run until an event (I/O op) completes. Why not swap it out? Memory space is available for other processes.
11
11 6-State Process Behavior Model When the swap-out operation is performed, there are two choices to select a process to bring into main memory. –A new processes being admitted –A suspended process A preference should be given on a suspended one –to execute and complete a partially-executed process, rather than increasing the total memory consumption. NewReadyRunningTerminated Waiting (Blocked) admitted Dispatched to a CPU interrupted I/O or event wait I/O or event completion exit Suspended Suspended (swapped) activated
12
12However… All suspended processes were in the blocked state at the time of suspension. –It makes no sense to bring a blocked (and suspended) process back in main memory. It is not ready for execution. Need to know whether a suspended process is still waiting for an event or ready for execution. New states needed –2x2 combination of (blocked or not) and (suspended or not)
13
13 7-State Process Behavior Model Ready: The process is in main memory and available for execution. Blocked: The process is in main memory and blocked on an event. Blocked, suspended: The process is in virtual memory and blocked on an event. Ready, suspended: The process is in virtual memory but is available for execution as soon as it is loaded to main memory. Ready, Suspended ReadyRunningTerminated Blocked activated Dispatched to a CPU interrupted I/O or event wait Event completion exit Blocked, Suspended Suspended New admitted activated
14
14 Blocked Blocked, suspended –When there are no ready processes. New processes can use freed memory. –When there are ready processes. Ready processes (and currently-running processes) can use more main memory. Ready, Suspended Ready Blocked activated Event completion Blocked, Suspended Suspended activated
15
15 Blocked, suspended Ready, suspended –Upon an event completion. Ready, suspended Ready –When there are no ready processes in main memory. Ready Ready, suspended –When a currently-running process requires more memory. Ready, Suspended Ready Blocked activated Event completion Blocked, Suspended Suspended activated
16
16HW1 Explain the transition “interrupted” and “event wait.” Describe how they are different. NewReadyRunningTerminated Waiting (Blocked) admitted Dispatched to a CPU interrupted I/O or event wait I/O or event completion exit
17
17HW2 CPU Ready Queue admitted dispatched exit interrupted Event 1 wait Event 1 occurs Event 1 Blocked Queue Event 2 wait Event 2 Blocked Queue Event 3 wait Event 2 occurs Event 3 occurs This process mgt scheme assumes that each process waits for an event. A process may want to wait for multiple events at the same time. When can this make sense? Provide an example. How do you design process queues?
18
18HW3 Choose an OS, and describe –Where the OS places virtual memory –How to configure (change) the total size of virtual memory on the OS.
19
19HW4 For the 7-state process behavior model –Draw a queuing diagram.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.