FCFS Program in Java with Arrival TimeWhat is FCFS scheduling algorithm?First Come, First Served (FCFS) is a non-primitive CPU scheduling algorithm. It schedules processes in the order in which they arrive in the ready queue. Processes are executed one by one until completion. What is arrival time?Arrival time is the time at which a process arrives in the ready queue. Non-primitive: Non-primitive scheduling is employed when a process terminates or transitions from running to waiting state. First in, first out (FIFO), also known as first come, first served (FCFS), is the simplest scheduling algorithm. FIFO simply queues processes in the order that they arrive in the ready queue. In this, the process that comes first will be executed first and next process starts only after the previous gets fully executed. Here, we are considering that arrival time for all processes is 0.
Implementation of FCFSFCFS Algorithm
Given n processes with their burst times, the task is to find average waiting time and average turnaround time using FCFS scheduling algorithm. FCFS.java Output: PID AT BT CT TAT WT 0 0 10 10 10 0 1 10 5 15 5 0 2 15 8 23 8 0 Avg_turnaround:7.666666666666667 Avg_Waitingtime:0.0 Service Time: Also known as Burst Time, it is the amount of time a process requires to complete its execution on the CPU. It represents the time the CPU spends executing instructions of that particular process. Waiting Time: It refers to the total amount of time that a process spends waiting in the ready queue before it gets a chance to execute on the CPU. Implementation of FCFS
Let's calculate the average waiting time and turnaround time for the following data.
FCFS.java Output: Average waiting time = 3.33333 Average turnaround time = 10.0 Next TopicImmutable Map in Java |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India