Tuesday, November 14, 2023

Process Scheduling


Process Scheduling

The two main objectives of the process scheduling system are
·         to keep the CPU busy at all times and
·         to deliver "acceptable" response times for all programs, particularly for interactive ones.

The process scheduler must meet these objectives by implementing suitable policies for swapping processes in and out of the CPU.

Scheduling Queues

  • All processes are stored in the job queue.
  • Processes in the Ready state are placed in the ready queue.
  • Processes waiting for a device to become available or to deliver data are placed in device queues. There is generally a separate device queue for each device.
  • Other queues may also be created and used as needed.


Schedulers

  • long-term scheduler or job scheduler selects processes from job pool and loads them into memory for execution

  • The short-term scheduler, or CPU Scheduler, selects from ready processes and allocates the CPU to one of them.

  • Some systems also employ a medium-term scheduler. When system loads get high, this scheduler will swap one or more processes out of the ready queue system for a few seconds, in order to allow smaller faster jobs to finish up quickly and clear the system.

  • An efficient scheduling system will select a good process mix of CPU-bound processes and I/O bound processes.

Context Switch

  • Whenever an interrupt arrives, the CPU must do a state-save of the currently running process, then switch into kernel mode to handle the interrupt, and then do a state-restore of the interrupted process.
  • Similarly, a context switch occurs when the time slice for one process has expired and a new process is to be loaded from the ready queue. This will be instigated by a timer interrupt, which will then cause the current process's state to be saved and the new process's state to be restored.
  • Saving and restoring states involves saving and restoring all of the registers and program counter(s), as well as the process control blocks described above.
  • Context switching happens frequently, and the overhead of doing the switching is just lost CPU time, so context switches need to be as fast as possible.
  • Context switch time is pure overhead and are highly dependent on hardware support.

0 comments:

Post a Comment

Data Structures with C++



NET/SET/CS PG



Operating Systems



Computer Networks



JAVA



Design and Analysis of Algorithms



Programming in C++

Top