Zarrar Ahmad Niazi

In search of fair and efficient use of the CPU

Abstract

The CPU performs the system's calculating and processing. The performance, design and speed of the CPU dictate the performance and speed of the complete system. The operating system creates a hierarchy of processes. It is operating system's job to schedule the resource of the CPU fairly and efficiently. This involves using time slice, assigning priorities to processes and using algorithm. When a process is not making full use of the CPU's time it is suspended and other process is assigned to CPU. This is called Interrupt. There are three level of scheduling High Level Scheduling, Intermediate Level Scheduling and Low Level Scheduling. There are many scheduling algorithms. The five most widely used are First in First out, Round Robin, Priority Scheduling, Guaranteed scheduling, Shortest Job First and Multilevel Scheduling.

 Area of investigation (Introduction)

I will be throwing light on the basic organisation of the CPU, rationing of the CPU time and how it is done. I am also gonna discuss Time slice scheduling, different level of scheduling, efficient usage of the CPU, scheduling objectives and main scheduling algorithms.

Central Processing Unit

The brain of the PC is processor, or Central Processing Unit (CPU). The CPU performs the system's calculating and processing -except for special math intensive processing in systems that have math coprocessing unit chip. The processor is easily the most expansive chip in the system. All the PC-Compatibles use processors that are compatible with the intel family of chips, although the processors themselves may have been manufactured or designed by various companies, including AMD, IBM, Cyrix and others.

 FUNDAMENTAL

The primary function of the CPU and other instruction-set processors is to execute sequence of instructions, that is programmes, which are stored in an external main memory. Program execution is therefore carried out as follows;

  1. The CPU transfers instructions and, when necessary, their input data (operands) from main memory to register in the CPU.
  2. The CPU executes the instructions in their stored sequence except when the execution sequence is explicitly altered by a branch instruction.
  3. When necessary the CPU transfers out put data (results) from the CPU registers to main memory.

Consequently, streams of instructions and data flow between the external memory and the set of registers that forms the CPU's internal memory. The efficient management of these instructions and data streams is a basic function of the CPU.

The performance, design and speed of the CPU dictate the performance and speed of the complete computer system. For example, data processing cannot be faster than that permitted by the CPU. A range of different process technologies exists, including microprocessors by Motorola and Intel.

The processor executes machine instructions residing in main memory. The instructions are provided in the form of programs. A program is a set of instruction. When a program runs it generates a process, that is, a process is a program in action. A processor may interleave the execution of a number of programs over time. From the point of view of an individual program, its execution involves a sequence of instructions with in the program. The execution of an individual program is referred to as a process or task. The operating system controls events within the computer system. It schedules and dispatches processes for execution by the processor, allocates resources to processes. A CPU can deal with one process at a time. There are almost always more processes running than the processor (CPU) can handle. If the operating system is to manage process and CPU resources, it must have information about the current status of each process and resource. The operating system must have the following information about a process if it is to manage and control a process. First it must know the location and second it must know the attributes of the process. Process Control Block contains all the information about a process. When a process is created process record is created. The operating system makes decisions about how long a process should get with the CPU (this is known as a time slice) and assign priorities to processes. For this purpose the operating system uses algorithm. To improve the efficiency of the CPU operating system removes the CPU from processes that are not making efficient use of the processor. 'Interrupts' are used to do this. For example if a process is printing information, it is not using CPU properly. So operating system removes the process from the CPU while data is being printed. The CPU resources are then assigned to another process. The process loses its place on the CPU as a result of a context switch. When the printing is finished the process is put back on a run queue at a newly calculated priority. It may or may not be the next process to run depending on this priority. The operating system periodically checks on the process to check if it is ready to be reallocated. This is called polling. Alternatively an 'Interrupt' is issued when process is ready to be put back in queue. All operating systems are consist of four managers, 1.Process Manager 2.Memory Manager 3.Device Manager 4.File manager. The job of the Process Manager is to fairly and efficiently schedule the resource of the CPU.

 Scheduling

There are three different levels of scheduling, High Level Scheduling, Intermediate Level Scheduling and Low Level Scheduling. High Level Scheduling is job scheduling that uses the algorithms. It is concerned with how long process has been swapped out. How much CPU times the process has had. Process size and priority. The Intermediate Level Scheduling takes off the systems load when it is overloaded. It temporarily suspends the processes. The lower level scheduling moves processes between the ready and running states. Low level scheduler manages processes in memory.

Scheduling criteria:

Process Scheduling

Scheduling Algorithms

Round Robin Scheduling

Priority Scheduling

Multiple Queue Scheduling

Shortest Job First Scheduling

Guaranteed Scheduling

First in First out

Discussion

Processes are OS conceptual models. Processes need to communicate. To avoid mutual exclusion and synchronisation issues semaphores; monitors, event counters, etc are used. Process scheduler is responsible for determine which process to run and when. There are many different scheduling algorithms and each algorithm is suited for different environments.

Conclusion

Operating system plays vital and basic role in the process scheduling. It is job of the Process Manager of operating system to fairly and efficiently schedule the resource of the central processing unit. Different scheduling algorithms suite different environments. For example it is impossible to predict the response time for first in, first out scheduling and therefore is not suitable for interactive systems.

Shortest job first relies on user's estimates of running time and is none pre-emptive. The response times are unpredictable. So that is unsuitable for real time and interactive environments.

1