A. PROCESS SCHEDULING QUEUES
Job Queue – When a process enters a system, it is put in a job queue.
- Ready Queue – set of all processes residing in main memory, ready and waiting to execute are kept in ready queue.
- Device Queues – There may be many processes in the system requesting for an I/O. Since only one I/O request can be entertained for a particular device, a process needing an I/O may have to wait. The list of processes waiting for an I/O device is kept in a device queue for that particular device.
An example of a ready queue and various device queues is shown below.
B. SCHEDULERS
- A process may migrate between the various queues.
- The OS must select, for scheduling purposes, processes from these queues.
- Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue.
- It is invoked very infrequently (seconds, minutes) Þ (may be slow).
- It controls the degree of multiprogramming.
- Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU.
- Short-term scheduler is invoked very frequently (milliseconds) Þ(must be fast).
- Midterm scheduler selects which partially executed job, which has been swapped out, should be brought into ready queue.
C. CONTEXT SWITCH
- When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process - this is called context switch.
- The time it takes is dependent on hardware support.
- Context-switch time is overhead; the system does no useful work while switching.
Steps in Context Switching
- Save context of processor including program counter and other registers.
- Update the PCB of the running process with its new state and other associate information.
- Move PCB to appropriate queue - ready, blocked,
- Select another process for execution.
- Update PCB of the selected process.
- Restore CPU context from that of the selected process.
0 comments:
Post a Comment