Below is a sample program that will simulate how processes are scheduled by the computer's operating system:
CPU Scheduling Algorithms:
FCFS - FIRST COME FIRST SERVE
How to Use CPU Scheduler
STEP 1: Select the # of CPU processes to use (1-10).
STEP 2: Select the scheduling algorithm
STEP 3: If using Round-Robin, then select the quantum
STEP 4: If using Priority Scheduling, type in the priorities for each process
STEP 5: Type in the burst times for each process. You can also press the "Random" button which will automatically generate random values for the burst times and priorities.
STEP 6: Press the "Calculate" button to determine average wait time and average turnaround time
* NOTE *: Use the Scroll bar at the bottom of the screen to scroll through the Gantt chart.
Swipe finger on Mobile device to scroll Gantt chart.
* NOTE *: If you decide to change any information you entered, you must press the "Calculate" button again.
- When a process enters CPU, the CPU to allocated to that process. The next process stays in a queue until the burst time is complete.
SJF - SHORTEST JOB FIRST
- Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time.
- A priority number (integer) is associated with each process
The CPU is allocated to the process with the highest priority (largest integer highest priority first).
- Each process gets a small unit of CPU time (time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units.
CPU Scheduling Terminology:
- actual time that is required to complete execution of particular task or process.
- amount of time a process has been waiting in the ready queue
Turnaround Time (T/A)
- amount of time to execute a particular process
- For Round Robin, the CPU will switch processes based on this value until the processes burst time is used up
- keep the CPU as busy as possible
- # of processes that complete their execution per time unit
- amount of time from when a request was submitted until the first response is produced.
Also visit our article on how a computer manages memory for these processes.