Scheduling simply means sharing the CPU it is crucial to understand that in single processor (uni-processor) computer system. only one program can execute at any point in time. Yet on a multi-user system all users have the impression that their program is the one currently executing. This is an illusion, achieved by the speed of the processor. The processor can execute millions of instruction per second. So, the operating system scheduler allocates the CPU to each user's program for a short period of Time called Quantum, usually a fraction of a second for example, 100  milliseconds. The CPU then executes that program until its time fraction expires. The scheduler then switches the CPU to another program for a fraction of a second so on. When the scheduler returns to executing the first program, it resumes the program at the point it was last executing at. Because of the speed of the CPU, it will normally have returned to a program, before a user realise that the program has not been executing.
They scheduler is a small, but important program whose basic function is to decide which program to run next and to start it. There are numerous scheduling policies used to decide which process gets the CPU next. one such policy is called the round robin policy where everyone gets an equal amount of CPU time in sequence so that no programs gets a second CPU quantum until every program has received a first quantum. Another scheduling policy is a priority scheduling policy where user programs are assigned higher or lower priorities. The scheduler gives high priority programs preference over low priority programs. (The  scheduler executes the program with the highest priority).

While priority scheduling seems very unfair, it works quite well in practice because of one important features of program execution, which is, that most programs carried out input and output operation.  This is important because of the mismatch in speed between the CPU and the input and output device of a computer. As mentioned earlier, it is 100,000 slower to access information on disk than to access information stored in RAM. Keyboard input compares to CPU speed in a similar fashion as snail speed compares to jet and aircraft speed. Thus while the CPU is waiting for an input and output operation to complete for one program, it can be switched by the scheduley to another program. Thus,  a high priority process that carries out input and output operation will not unduly hog the CPU from other program. It has been observed that process execution involves periods of CPU execution and period of input and output wait (waiting for an input and output operation to complete). Process alternate between these two states. Programs may be classified as input and output Bound is the exhibit many short CPU bursts (typical file processing program) intermingled with input and output wait. There are CPU bound if there exhibit a few very long CPU bursts. A high priority CPU bound process will indeed  hog the CPU and the response time for other user will suffer as a consequence.

Post a Comment