CPU scheduling process scheduling algorithm

Source: Internet
Author: User
1.Preemptive Scheduling
CPU scheduling decisons may take place under the following four conditions:

1. When a process switches from running state to the waiting state (for example, I/O request, or invocation of waif wait for the termination of one of the Child processes)

2. When a process switches from the running state to the ready state, for example, when an interupt occurs

3. When a process switches from the waiting state to the ready state, for example, completion of I/O.

4. When a process terminates.

When scheduling takes place only under circumstances 1 and 4, we say the scheduling cheme is Nonpreepmtive ; Otherwise, the schedulign is preemptive.

2. Dispatcher
The dispatcher is the module that gives control of the CPU to the process selected by the short-term schedves. This function involves:
Switching context;
Switching to user mode;
Jumping to the proper location in the user program to the restart that program.
The dispatcher shoshould be as fast as possible, given that it is invoked during every process switch. The time it takes for the dispatcher to stop one process and start anohter running is known asDispatch latency.

3 scheduling criteria
1. CPU utilization :
We want to keep the CPU as busy as possible. CPU utilization may range from 0 to 100 percent. In a real system, It shocould range from 40 percent to 90 percen.
2. throughput:
If the CPU is busy executing processes, then work is being done. One measure of work is the number of processes completed per time unit, called throughput.
3. Turnaround time:
From the point of view of a participant process, the important criterion is how long it takes to execute that process. the inverval from the time of submission of a process to the time of completion is the turnaround time. turnaround time is the sum of the periods spent waiting to get into memory, waiting in the ready queue, executing on the CPU, and doing I/O.
4. Waiting Time & response time.

4. Scheduling Algorithms
CPU scheduling deals with the problem of deciding which of the processes in the ready queue is to be allocated the CPU.
1. FCFS (first come fist served scheduling)
With this schema, the process that requests the CPU first is allocated the CPU first. the implemention of the FCFS policy is easily managed with a FIFO queue. when the CPU is free, it is allocated to the process at the head of the queue. the running process is then removed form the queue.
2. Shortest-job-First Scheduling (SJF scheduling)
The algorithm associates with each process the length of the latter's next CPU burst. when the CPU is available, it is assigned to the process that has the smallest next CPU burst. if two processes have the same length next CPU burst, FSCs schedulign is used to break the tie.
The SJF schedulig algorithm is probably opitmal. the real difficulty with the SJF algorithm is Knowning the length of the next CPU burst. there is no way to know the length of the next CPU burst.
3. Priority Scheduling
The SJF algorithm is a special case of the general priority-scheduling algotithm. A priority is assolcaited with each process, and the CPU is allocated to the process with the highest priority. equal-priority processes are schuduled in FCFS order.
An SJF algorithm is simply a priority algorhm where the priority is the inverse of the (predicted) Next CPU burst. The larger the CPU burst, the lower the priority.
A major problem with priority-scheduling algorithms is indefinte blockhing (or starvation ). in a HEAVlLY loaded computer system, a steady stream of higher-priority processes can prevent a low-priority process from ever getting the CPU.
A solution to the problem of indefinite blockage of low-priority processes is aging. aging is a technique of gradually increasing the priority of the processes taht wait in the system for a long time. for example, if priorities range from 127 (low) to 0 (high), We cocould decremet the priority of a waiting process by 1 every 15 minites. eventually, even a process with an initial priority of 127 wocould have the highest priority in the sytem and wocould be executed.
4. Round-Robin Scheduling
The round-robin (RR) scheduling is designed especially for time-sharing system. it is similiar to FCFS scheduling, but preemption is added to switch between process. A small unit a time, called a time quantum (or time slice), is defined. A time quantum is generally from 10 to 100 miliseconds. the read queue is treated as a curcular queue. the CPU schedule goes around the ready queue, allocating the CPU to each process for a time interval of up to 1 time quantum.
5. Multi-Level queue Scheduling
A multi-level queue-scheduling algorithm partitions the ready queue into several separate queues. the processes are permanently assisgned to one queue, generally based on some property of the process, such as memory size, process priority, or process type. each queue has its own scheduling algorithm.
6. Multi-Level Feedback queue Scheduling
Normally, in a multi-level queue-scheduling algorithm, processes are permanently assigned to a queue on entry to the system. processes do not move between queues.
Multi-level feedback queue-scheduling algorithm, however, allows a process to move between queues. the idea is to separate processes with different CPU-Burst Characteristics. if a process uses too much CPU time, Ti will be moved to a lower-priority queue.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.