CPU-Scheduling-Scheduler-CPU-I/O Burst Cycle


CPU Scheduling

CPU scheduling is a process which allows one process to use the CPU while the execution of another process is on hold(in waiting state) due to unavailability of any resource like I/O etc, thereby making full use of CPU. The aim of CPU schedulingis to make the system efficient, fast and fair.
Scheduling is a fundamental operating-system function. Almost all computer resources are scheduled before use. The CPU is, of course, one of the primary computer resources. Thus, its scheduling is central to operating-system design.

CPU-I/O Burst Cycle

The success of CPU scheduling depends on the following observed property of processes: Process execution consists of a cycle of CPU execution and I/O wait. Processes alternate between these two states. Process execution begins with a CPU burst. That is followed by an I/O burst, then another CPU burst, then another I/O burst, and so on. Eventually, the last CPU burst will end with a system request to terminate execution, rather than with another I/O burst.
The durations of these CPU bursts have been extensively measured.
Although they vary greatly by process and by computer, they tend to have a frequency curve similar to that shown in Figure.
The curve is generally characterized as exponential or hyper exponential, with many short CPU bursts, and a few long CPU bursts.
An I/O-bound program would typically have many very short CPU bursts. A CPU-bound program might have a few very long CPU bursts. This distribution can help us select an appropriate CPU-scheduling algorithm.

CPU Scheduler

Whenever the CPU becomes idle, the operating system must select one of the processes in the ready queue to be executed. The selection process is carried out by the short-term scheduler (or CPU scheduler). The scheduler selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them.


The ready queue is not necessarily a first-in, first-out (FIFO) queue. As we shall see when we consider the various scheduling algorithms, a ready queue may be implemented as a FIFO queue, a priority queue, a tree, or simply an unordered linked list. Conceptually, however, all the processes in the ready queue are lined up waiting for a chance to run on the CPU. The records in the queues are generally process control blocks (PCBs) of the processes.
One approach to scheduling is known as preemptive scheduling: "this task is accomplished by dividing time into short segments, each called a time slice or quantum (typically about 50 milliseconds), and then switching the CPU's attention among the processes as each is allowed to execute for no longer than one time slice." This procedure of swapping processes is called a process switch or a context switch.
Another approach to scheduling is non-preemptive scheduling. In this approach, processes are given control of the processor until they complete execution or voluntarily move themselves to a different state. Employing this type of scheduling poses a potential problem, however, since processes may not voluntarily cooperate with one another. This problem is especially serious if the running process happens to be executing an infinite loop containing no resource requests. The process will never give up the processor, so all ready processes will wait forever". For this reason, few systems today use non-preemptive scheduling.


Comments