Process Scheduling

The objective of multiprogramming is to have some process running at all times, to maximize CPU utiliztion. The objective of time sharing is to switch the CPU among processes so frequently that users can interact with each program while it it running.

Scheduling Queues

A common representation of process scheduling is queueing diagram.

  • Job Queue - consists of all processes in the system.
  • Ready Queue - consists of processes that are residing in main memory and are ready and waiting to execute

Once the process is allocated on the CPU and is executing, one of several events could occur:

  • The process could issue an I/O request and then be placed in an I/O queue.
  • The process could create new child process and wait for the child's termination.
  • The process could be removed forcibly from the CPU, as a result of an interrupt and can be put back to ready queue.

Scheduler

  • Processes are spooled to a mass-storage device
  • Job scheduler selects processes from this pool and loads them into memory for execution.
  • CPU scheduler selects from among these processes that are ready to execute and allocates the CPU to one of them.

Job scheduler vs CPU scheduler

  • The primary distinction between these two schedulers lies in frequency of execution.
  • CPU scheduler must select a new process for the CPU frequently
  • The job scheduler executes much less frequently
  • The job scheduler controls the degree of multiprogramming (the number of processes in memory)

In general, most processes can be described as either I/O bound or CPU bound

  • An I/O bound process is one that spends more of its time doing I/O than it spends doing computations.

It is important that the long-term scheduler select a good process mis of I/O bound and CPU-bound processes.

The system with the best performance will thus have a combination of CPU-bound and I/O-bound processes.

Context Switch

Switching the CPU to another process requires performing a state save of the current process and a state restore of a difference process.

Context switch time is pure overhead, because the system does no useful work while switching. A typical speed is a few milliseconds.

results matching ""

    No results matching ""