0% found this document useful (0 votes)
0 views

CPU Scheduling Algorithms

The document compares two CPU scheduling algorithms: First-Come, First-Served (FCFS) and Round Robin (RR). FCFS is a non-preemptive method that processes tasks in the order of arrival, leading to potential inefficiencies, while RR is a preemptive method that allocates fixed time slices to processes, ensuring fair CPU usage but requiring context switching. Key differences include preemption, fairness, efficiency, and complexity.

Uploaded by

Lohith Mopidevi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

CPU Scheduling Algorithms

The document compares two CPU scheduling algorithms: First-Come, First-Served (FCFS) and Round Robin (RR). FCFS is a non-preemptive method that processes tasks in the order of arrival, leading to potential inefficiencies, while RR is a preemptive method that allocates fixed time slices to processes, ensuring fair CPU usage but requiring context switching. Key differences include preemption, fairness, efficiency, and complexity.

Uploaded by

Lohith Mopidevi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

### a) **First-Come, First-Served (FCFS)**

#### Overview:
- **First-Come, First-Served (FCFS)** is the simplest CPU scheduling algorithm.
- It is a **non-preemptive** scheduling algorithm, meaning once a process starts
executing, it cannot be interrupted until it completes.
- Processes are executed in the order of their arrival in the ready queue.

#### Characteristics:
1. **Queue-based:** Processes are maintained in a FIFO (First In, First Out) queue.
2. **Fair but Inefficient:** All processes are treated equally based on arrival
time, but it may lead to poor CPU utilization.

#### Advantages:
- Simple to implement.
- Easy to understand.
- No complex decision-making required during execution.

#### Disadvantages:
- **Convoy Effect:** Short processes get stuck waiting behind long processes.
- Not suitable for interactive systems.
- Poor average waiting time for a mix of short and long processes.

#### Example:
| Process | Arrival Time | Burst Time | Execution Order | Completion Time |
Turnaround Time | Waiting Time |
|---------|--------------|------------|-----------------|-----------------|--------
---------|--------------|
| P1 | 0 | 4 | 1 | 4 | 4
| 0 |
| P2 | 1 | 3 | 2 | 7 | 6
| 3 |
| P3 | 2 | 2 | 3 | 9 | 7
| 5 |

#### Formulas:
- **Turnaround Time (TAT):** Completion Time - Arrival Time
- **Waiting Time (WT):** Turnaround Time - Burst Time

---

### b) **Round Robin (RR)**

#### Overview:
- **Round Robin (RR)** is a **preemptive** scheduling algorithm.
- Each process is assigned a fixed **time quantum** (or time slice) during which it
can execute.
- After the time quantum expires, the process is moved to the end of the ready
queue, and the next process gets CPU time.

#### Characteristics:
1. **Time-sharing system:** Ideal for time-sharing and interactive systems.
2. **Fair allocation:** Ensures all processes get equal CPU time in cycles.
3. **Context Switching:** Frequent context switching can impact performance.

#### Advantages:
- Suitable for systems where response time is crucial.
- Prevents long processes from blocking shorter ones.
- Ensures fair allocation of CPU time.

#### Disadvantages:
- Context-switching overhead is high.
- Poor performance if the time quantum is not chosen carefully:
- Too small: High context-switching overhead.
- Too large: Behaves like FCFS.

#### Example:
| Process | Arrival Time | Burst Time | Time Quantum = 2 |
|---------|--------------|------------|-------------------|
| P1 | 0 | 5 | Executes: [0-2], [4-6], [8-9] |
| P2 | 1 | 3 | Executes: [2-4], [6-7] |
| P3 | 2 | 2 | Executes: [7-8] |

- **Completion Time for P1:** 9


- **Completion Time for P2:** 7
- **Completion Time for P3:** 8

#### Formulas:
- **Turnaround Time (TAT):** Completion Time - Arrival Time
- **Waiting Time (WT):** Turnaround Time - Burst Time

---

### Key Differences Between FCFS and Round Robin:


| Aspect | FCFS | Round Robin
|
|-----------------------|---------------------------|------------------------------
--|
| **Preemption** | Non-preemptive | Preemptive
|
| **Fairness** | May cause starvation | Equal time allocation
|
| **Efficiency** | Inefficient for interactive systems | Suitable for
interactive systems |
| **Complexity** | Simple | Requires context-switching
overhead |

You might also like