Advertisement

real time scheduling in operating system and Types of Schedules

Types of Schedules

Long-Term Scheduler or Job Scheduler or admission schedule
selects processes present in the Job Queue and loads them into memory for execution.

Short-Term Scheduler or CPU Scheduler select processes that are ready to execute from the ready queue and allocates the CPU to one of them.
Generally, the short-term scheduler selects new processes for CPU quite often. The short-term scheduler must be very fast. If a short-term scheduler takes 1 msec to decide to execute a process for 10 msec then 1/(10+1) = 9 percent of the CPU is used/wasted just for scheduling the work.
Long-term schedulers do not execute frequently. As compared to the short-term scheduler, a long-term scheduler executes less frequently. The long-term scheduler controls the degree of Multiprogramming. If the average rate of process creation is equal to the average departure rate of process leaving the system, then it means that the degree of multiprogramming is stable.
It is important that the long-term scheduler select a good process mix of I/O bound and CPU bound processes. Best performance of the system will be achieved if we have a combination of CPU bound and I/O bound processes.


Medium-Term or mid-term Scheduler removes processes from memory in order to reduce the degree of Multiprogramming.
Generally, the Medium-Term scheduler is used in Time Sharing systems and when a system is heavily loaded with processes then Medium-Term scheduler removes some processes from memory and later those processes are brought back into memory so that they continue their execution from where they were left.
The mid-term scheduler temporarily removes processes from main memory and places them on secondary memory (such as a disk drive) or vice versa. This is commonly referred to as "swapping out" or "swapping in".
The mid-term scheduler may swap out a process when
·                 It is not active for some time
·                 Its priority is low
·                 It has increased page-fault rate
·                 It is consuming a large amount of memory
·                 A process has been unblocked and is no longer waiting for a resource.

Process State Diagram with Medium Term Scheduler

process scheduling software


















CPU Bound or CPU Intensive Processes
CPU Bound or CPU Intensive processes spend more of their time doing computations etc and generate I/O requests infrequently.

I/O Bound or I/O Intensive Processes

I/O Bound or I/O Intensive processes spend more of their time doing I/O etc and generate CPU requests infrequently.


CPU Scheduling

When the CPU becomes idle, the Operating System must select one of the processes in the ready queue to be executed, this selection is done through short-term or CPU scheduling.

Scheduling decisions take place

1.               When a process switches from running to waiting for the state.
2.               When a process switches from running state to the ready state.
3.               When a process switches from the waiting state to ready state.
4.               When a process terminates.

Non-Preemptive Scheduling Scheme

On switching a process from running to waiting for state or on process termination, a new process must be selected for execution, and the scheduling scheme used in such a situation is called non-preemptive scheduling scheme.

Preemptive Scheduling Scheme

On switching a process from running to ready state or on switching from waiting to a ready state, the scheduling scheme is called preemptive scheduling scheme.

Context Switch

Switching the CPU to another process requires saving the state of the old process and loading the saved state for the new process. This task is known as a context switch. Context Switch time is pure overhead and depends upon the speed of memory and number of registers etc.