CPU programming is a process that allows one process to use the CPU while the execution of another process is on hold (in standby) due to the unavailability of any resources such as I / O, etc., thus taking advantage of the CPU . The purpose of CPU programming is to make the system efficient, fast and fair.
Programming Criteria
There are many different criteria to verify when considering the "best" programming algorithm:
• CPU utilization
To make the best use of the CPU and not lose any CPU cycle, the CPU would be working most of the time (ideally 100% of the time). Given a real system, CPU usage should range from 40% (slightly loaded) to 90% (heavily loaded).
• Performance
It is the total number of completed processes per unit of time or rather say the total amount of work done in a unit of time. This can vary from 10 / second to 1 / hour depending on the specific processes.
• Response time
It is the amount of time it takes to execute a particular process, that is, the interval from the moment the process is presented to the end of the process (wall clock).
• Wait time
The sum of waiting periods in the queue lists the amount of time a process has been waiting in the queue ready to acquire get control on the CPU.
• Average load
It is the average number of processes that reside in the ready queue waiting their turn to enter the CPU.
• Response time
Amount of time it takes since an application was submitted until the first response occurs. Remember, it is the time until the first response and not the completion of the process execution (final response).
In general, CPU utilization and performance are maximized and other factors are reduced for proper optimization.
Programming Algorithms
Let's discuss four main programming algorithms here that are following:
1. Programming of First Come First Service (FCFS)
2. Programming the shorter work schedule (SJF)
3. Priority programming
4. Round Robin Programming (RR)
5. Programming Multilevel Queues