what is CPU scheduling? definition and types of schedulars. - Cyber security & Technology

Breaking

Follow by Email

Monday, August 13, 2018

what is CPU scheduling? definition and types of schedulars.





CPU SCHEDULING


DEFINITION  

·        Scheduling is a fundamental operating system function.

·        Scheduling refers to set of policies and mechanisms built into the operating system that governs the order in which the work to be done by a computer system is completed.

·        CPU scheduling is the basis of multi-programmed operating system. By switching the CPU among processes, the operating system can make the computer more productive.

·        In a multiprogramming environment, multiple processes are kept in main memory at one time. When one process has to wait for completion of VO request, the operating system takes the CPU from that process and assigns it to another process. In this way, CPU is never idle and has some process to work on.

SCHEDULER

·        A scheduler is an operating system module that selects the next job or process to be admitted into the system.

·        Thus, a scheduler selects one of the process from among the processes in the memory that are ready to execute and allocates CPU to it.

·        In a complex operating system three different types of schedulers may exist. These are:

1.     Long-term scheduler

2.      Medium term scheduler

3.      Short term scheduler

Figure  shows the various queues and the various schedulers that are responsible for selecting the processes from these queues.







·        Figure shows that a submitted job joins the batch queue while waiting to be processed by the long-term scheduler.

·        Once a process is scheduled for execution, the process spawned by the batch job enters the ready queue where it waits for the allocation of processor. The processes in ready queue are selected for the execution by the short term scheduler.

·        After becoming suspended, the running process may be removed from memory and swapped out to secondary storage. Such processes are subsequently admitted to main memory by the

medium-term scheduler in order to be considered for execution by the short term scheduler.



1.      Long-term Scheduler

·        The long term scheduler works with batch queue and selects the next batch job to be executed. Thus it plans the CPU scheduling for batch jobs.

·        Processes, which are resource intensive and have a low priority are called batch jobs. These jobs are executed in a group or bunch. For example, a user request for printing a bunch of files.

·        We can also say that a long term scheduler selects the processes or job from secondary storage device e.g. a disk and loads them into the memory for execution. It is also known as job scheduler.

·        The frequency of execution of a long-term scheduler is usually low, as there may be minutes between the creation of new processes in the system.

·        The long term scheduler is called "long-term" because the time for which the scheduling is valid is long. .

·        The primary objective of long term scheduler is to control the degree of multiprogramming. The degree of multiprogramming refers to the total number of processes present in the memory. If the degree of multiprogramming is stable, then the average rate of process creation is equal to the average departure rate. Therefore the long-term scheduler may need to be invoked only when the process leaves the system.

·        This scheduler shows the best performance by selecting the good process mix of I/O bound and CPU-bound process. I/O bound processes are those that spend most of their time in IVO than computing. A CPU bound process are those that spend most of their time in computations rather than generating I/O requests .

·        On some systems, the long-term scheduler may be absent or minimal. For example, timesharing systems such as UNIX often have no long term scheduler but simply put every new process in memory for the short term scheduler.

2.      Medium term Schedulers

·        The medium term scheduler is required at the times when a suspended or swapped-out process is to be brought into pool of ready processes.

·        A running process may be suspended because of VO request or by a system call. Such a suspended process is then removed from main memory and is stored in swapped out queue in the secondary memory in order to create a space for some other process in the main memory.

·        This is done because there is a limit on the number of active processes that can reside in main memory.

·        Therefore, a suspended process is swapped-out or rolled out of main memory.

·        At some later time, the process can be reintroduced i.e. swapped in the main memory so that it can continue where it left off.

·        Thus, swapping is required to control the degree of multiprogramming. All version of windows operating system use swapping.

·        The medium-term scheduler is in-charge of handling swapped out process. It has nothing to do, when a process remain suspended. However once the suspending condition is removed, the medium terms scheduler attempts to allocate the required amount of main memory and swap the process in make it ready.

·        Thus, medium term scheduler plans the CPU scheduling for processes that have been waiting for completion of another process or an I/O task.

·        To work properly, the medium term scheduler must be with information about the memory requirements of swapped out process

3.      Short-term Scheduler

·        The short-term scheduler selects from among the ready processes that are residing in the main memory and allocates CPU to one of them.

·        Thus, it plan the scheduling of the processes that are in ready state.

·        Short term scheduler is also known as CPU scheduler.

·        As compared to long term schedulers, a short term scheduler has to work very often i.e. the frequency of execution of short-term scheduler is high.

·        The short term scheduler must select a new process for CPU frequently. A process may execute for only a few milliseconds before waiting for an I/O request. Often, the short-term scheduler executes at least once every 100 milliseconds. Because of the brief time between executions, the short-term scheduler must be fast.

·        The short-term scheduler is invoked whenever an event occurs. Such an event may lead to the interruption of the current process or it may provide an opportunity to preempt the current running process in favour of another. The example of such events are: .

1.      Clock-ticks (time based interrupts)

2.      I/O interrupts and LO completions.

3.      Operating system calls.

4.      Sending and receiving of signals.

5.      Activation of interactive program.

No comments:

Post a Comment