Subscribe by Email


Showing posts with label CPU Scheduling. Show all posts
Showing posts with label CPU Scheduling. Show all posts

Thursday, May 2, 2013

What is a CPU Scheduler?


Scheduling is a very important concept when it comes to the multi-tasking operating systems. 
- It is the method via which the data flows, threads and processes are provided access to the shared resources of the computer system. 
- These resources include communications bandwidth, processor time, and memory and so on. 
- Scheduling is important as it helps in striking a balance the system processor and its resources effectively. 
- It helps in achieving the target QoS or quality of service. 
But what gave rise to scheduling? 
- Almost all the modern systems require to carry out multiple tasks i.e., multi-tasking and multiplexing as well which require a scheduling algorithm. 
Multiplexing means transmission of the multiple data flows at the same time. - There are some other things also with which the scheduler is concerned. They are:
  1. Throughput: It is the ratio of total number of processes executed to a given amount of time.
  2. Latency: This factor can be sub – divided in to two namely response time and the turnaround time. Response time is the time taken from the submission of the process till its output is produced by the processor. The latter i.e., the turnaround time is the time period elapsed between the process submission and its completion.
  3. Waiting/ fairness time: This is the equal CPU time given to each process or we can say that the time is allocated as per the priority of the processes. The time for which the processes wait in the ready queue is also counted in this.
- But in practical, conflicts may arise between these goals such as in case of latency versus throughput. 
- If such a case occurs, a suitable compromise has to be implemented by the scheduler. 
- The needs and the objectives of the user are used for deciding to who (of the above concerns) the preference is to be given. 
- In robotics or embedded systems i.e., in the real time environments, it becomes a duty of the scheduler for ensuring that all the processes meet their deadlines. 
- This is important for maintaining the stability of the system. 
- The mobile devices are given the scheduled tasks which are then managed by an administrative back end.

Types of CPU Schedulers

There are many types of CPU schedulers as discussed below:
1. Long-term Schedulers: 
- These schedulers facilitate the long term scheduling and are also known as the high level schedulers and the admission schedulers. 
- It is up to them to determine which processes and jobs are to be sent to the ready queue. 
- When the CPU makes an attempt for executing a program, the long term scheduler has the right to decide whether this program will be admitted to the currently executing set of processes. 
- Thus, it is dictated by this scheduler what processes are to be run and the extent of the concurrency has to be there.
- It also decides what amounts of processes have to be concurrently executed. 
It also decides the handling of the split between the CPU intensive and I/O processes.  

2. Medium-term Schedulers: 
- The processes are temporarily removed from the main memory and placed up on the secondary memory by this scheduler. 
- This process is called “swapping in” and “swapping out”. 
- Usually this scheduler swaps out the following processes:
a)   processes that have been inactive since some time
b)   the processes that has raised a frequent page faulting
c)   processes having a low priority
d) processes that take up large memory chunks for releasing the main memory to other processes
- The scheduler later swaps in these processes whenever sufficient memory is available and if the processes are unblocked and not in waiting state.

3. Short-term Schedulers: 
It takes decision regarding the processes to be executed after clock interrupt. 


Thursday, January 21, 2010

Thrashing and its Causes

It is technically possible to reduce the number of allocated frames to the minimum, there is some number of pages that are in active use. If the process does not have this number of frames, it will very quickly page fault. At this point, it must replace some page. However, since all its pages are in active use, it must replace a page that will be needed again right away. Consequently it very quickly faults again, and again, and again. The process continues to fault, replacing pages for which it will then fault and bring back in right away. This high paging activity is called thrashing. A process is thrashing if it is spending more time paging than executing.
Thrashing results in severe performance problems. If you consider the scenario below you will understand how early paging systems behaved :
CPU utilization is monitored by the operating system. If the system finds that CPU utilization is too low, multiprogramming is increased by adding a new process; the algorithm used replaces pages without considering their linked processes. However, a process may end up needing more frames and takes pages away from other processes, causing faulting. The processes from which those pages were taken away in turn will pull pages from other processes increasing the degree of faulting. As processes queue up for the paging device and end up waiting for pages, CPU utilization decreases, in turn causing a push to increase the degree of multiprogramming. This process will keep on happening with CPU utilization decreasing even further and the CPU scheduler trying to increase multiprogramming even further. This leads to thrashing and consequent decrease in system throughput (accompanied by a large increase in page fault rate).


Wednesday, August 26, 2009

CPU / Process Scheduling

CPU scheduling is the basis of multi-programmed operating systems. By switching the CPU among processes, the operating system can make the computer more productive. A multiprogramming operating system allows more than one process to be loaded into the executable memory at a time and for the loaded process to share the CPU using time-multiplexing.

Goals for Scheduling :
* Utilization/Efficiency: keep the CPU busy 100% of the time with useful work.
* Throughput: maximize the number of jobs processed per hour.
* Turnaround time: from the time of submission to the time of completion, minimize the time batch users must wait for output.
* Waiting time: Minimize the waiting time i.e. sum of times spent in ready queue.
* Response Time: time from submission till the first response is produced, minimize response time for interactive users.
* Fairness: make sure each process gets a fair share of the CPU.

Some goals can be met by incorporating a notion of priority into a “base” scheduling discipline. Each job in the ready pool has an associated priority value; the scheduler favors jobs with higher priority values.
External priority values:
• imposed on the system from outside.
• reflect external preferences for particular users or tasks.
“All jobs are equal, but some jobs are more equal than others.”
• Example: Unix nice system call to lower priority of a task.
• Example: Urgent tasks in a real-time process control system.

Internal priority: system adjusts priority values internally as as an implementation technique within the scheduler. It improves fairness, resource utilization, freedom from starvation.
• drop priority of jobs consuming more than their share
• boost jobs that already hold resources that are in demand
e.g., internal sleep primitive in Unix kernels
• boost jobs that have starved in the recent past
• typically a continuous, dynamic, readjustment in response to observed conditions and events may be visible and controllable to other parts of the system.

Scheduling policies may be preemptive or non-preemptive.
* Non-Preemptive: Non-preemptive algorithms are designed so that once a process enters the running state(is allowed a process), it is not removed from the processor until it has completed its service time ( or it explicitly yields the processor).
* Preemptive: Preemptive algorithms are driven by the notion of prioritized computation. The process with the highest priority should always be the one currently using the processor. If a process is currently using the processor and a new process with a higher priority enters, the ready list, the process on the processor should be removed and returned to the ready list until it is once again the highest-priority process in the system.


Facebook activity