Professional Documents
Culture Documents
Os Project Final
Os Project Final
Operating system
SUBMITTED BY :
MARYAM WASEEM (2022 BSE-059)
SUBMITTED TO :
DR. MEHREEN SIRSHAR
TOPIC:
SCHEDULING ALGORITHM
principle of "first come, first served," meaning that the process that arrives first is the one that
1. Arrival of processes:
The process that arrives first is the one that will be scheduled
2. Execution:
When the CPU is available, the process at the front of the ready queue is selected for
execution.
The selected process runs until it completes its execution or is interrupted by another
3.ComPletion:
Once a process completes its execution, the next process in the ready queue is selected
for execution.
4. Waiting time:
The waiting time for a process is the total time it spends waiting in the ready
5. Turnaround time:
Turnaround time is the total time taken by a process to complete its execution,
6. Advantages:
7. Disadvantage:
The "convoy effect" can occur, where shorter processes get stuck waiting behind
a long process.
Example:
Consider three processes, P1, P2, and P3, arriving in the order P1, P2, P3.
If the burst times for P1, P2, and P3 are 10, 6, and 8 units, respectively, the execution
Waiting Time
-------------------------------------------------------------------------------
P1 |0 | 10 | 10 | 10 |0
P2 |0 |6 | 16 | 16 | 10
P3 |0 |8 | 24 | 24 | 16
In the example, the completion time for each process is calculated as the sum of
the burst times of all previous processes. The turnaround time is the time from
Buying a movie ticket at the counter is another real-life example of FCFS (First
Come First Serve) scheduling. Here's a scenario to illustrate how FCFS works in
this context:
Imagine you arrive at a movie theater to purchase a ticket. There's a single ticket
counter, and several people are waiting in line to buy tickets. Each person in the
line is served in the order they arrived.
1. Person A: Arrives at the counter at 5:00 PM.
2. Person B: Joins the queue behind Person A at 5:05 PM.
3. Person C: Joins the queue behind Person B at 5:10 PM.
In this FCFS scenario:
The ticket seller serves Person A first because they were the first in line.
Once Person A completes the purchase, the ticket seller serves Person B
next.
Finally, after Person B completes the purchase, Person C is served.
The order of service strictly follows the order in which people arrived at the ticket
counter. This ensures fairness, as individuals who queued up earlier are served
before those who arrived later. FCFS is a straightforward and easy-to-understand
scheduling approach, making it suitable for scenarios like buying movie tickets
where fairness in service order is important.
2) Printer queue
In a real-life example of a printer queue using the FCFS (First Come First Serve)
scheduling algorithm, imagine an office environment where multiple users share
a single printer. Each user sends print jobs to the printer, and the jobs are
processed in the order they are received.
Let's consider a scenario with three users, each submitting a print job to the
printer: