Presentation is loading. Please wait.

Presentation is loading. Please wait.

Day 08 Processes.

Similar presentations


Presentation on theme: "Day 08 Processes."— Presentation transcript:

1 Day 08 Processes

2 Can you think of the states in a 5-state model?

3 i.e. 5-state model

4 Suspended Processes Processor is faster than I/O so all processes in main memory could be waiting for I/O Swap these processes to disk to free up main memory Blocked process becomes a suspended process when swapped to disk

5 One Suspend State

6 7-state model - two suspend states

7 Reasons for Process Suspension

8 Modes of execution User mode – restricted access to memory and restricted access to certain instructions. Kernel mode or system mode – when the OS is in control. Access to privileged instructions.

9 Mode switch How to set and reset the mode?
Hardware level support required. Mode bit (part of the Process Status Word) When an interrupt is detected, control is transferred to the OS (i.e. privileged mode is required) Change the mode bit When the interrupt service routine is done, control is transferred back to a user program (i.e. non-privileged mode) Change the mode bit again.

10 Process switching When can a process switch occur? Examples:
Anytime the OS takes over from the user process. Examples: Interrupt – external to the currently running process – clock INT, I/O interrupt, memory fault (page or segment) Trap – error exception internal to the program may have a recovery procedure or simply notify and quit Supervisor call – explicit request from the program (system call).

11 Process Switching – Supervisor call

12 Process switching – Timer interrupt

13 Context/mode switch Context/mode switch - When the processor switches between a user process and an OS process or vice versa. Involves the following steps: Set the PC value to the address of the ISR. Change to kernel model so that the ISR may access privileged instructions. Save the context of the process i.e. the general purpose registers, stack information, and PC value.

14 Context switch or Process switch?
When a context switch occurs, the PCB of the process that was running is still marked Running and is not placed in the Blocked or Ready queue. However, depending on what caused the context switch, a process switch could follow.

15 Process switch When the processor switches between two user processes.
Save the context of the current process Update the PCB to the new state. Move the PCB to new queue Select another process for execution Update the PCB of the next process Move the PCB of the next process to Running Update memory-mgmt data structures Restore the context of the processor to that of the new process. Lots of work! Design goal: Minimize the number of process switches.


Download ppt "Day 08 Processes."

Similar presentations


Ads by Google