29.4.25

preemptive scheduling and non preemptive schedulers

Types of Scheduling in Operating Systems

1. Preemptive Scheduling

In preemptive scheduling, a running process can be interrupted and moved to a ready state to allow another process to run.

Type Description
Round Robin (RR) Each process is assigned a fixed time slice in rotation.
Shortest Remaining Time First (SRTF) The process with the least remaining time is prioritized.
Priority Scheduling Processes are scheduled based on priority and can be preempted.

2. Non-Preemptive Scheduling

In non-preemptive scheduling, once a process starts executing, it runs to completion without interruption.

Type Description
First-Come, First-Served (FCFS) Processes are executed in the order they arrive.
Shortest Job First (SJF) Processes with the shortest execution time are scheduled first.
Priority Scheduling Processes are executed based on priority, cannot be preempted once started.

3. Hybrid Scheduling

Combines elements of both preemptive and non-preemptive scheduling to optimize performance.

4. Multilevel Queue Scheduling

Processes are divided into different queues based on specific criteria, each with its own scheduling algorithm.

5. Multilevel Feedback Queue Scheduling

Allows processes to move between queues based on their behavior and requirements.

6. Real-Time Scheduling

Designed for real-time tasks, ensuring timely execution.

Type Description
Hard Real-Time Guarantees that critical tasks will complete within a specified time.
Soft Real-Time Aims for timely task completion but does not guarantee it.

7. Batch Scheduling

Processes are collected and executed in batches without user interaction during execution.

8. Interactive Scheduling

Designed for user-interactive tasks, providing quick response times.

9. Fair Share Scheduling

Allocates resources based on the number of users or processes, ensuring fairness among them.

10. Load Balancing Scheduling

Distributes workloads evenly across multiple resources to optimize utilization.

Scheduling Algorithms Calculations

Exercise 1: First-Come, First-Served (FCFS)

Processes: P1 (Arrival: 0, Burst: 6), P2 (Arrival: 1, Burst: 8), P3 (Arrival: 2, Burst: 7)

Calculations:

Process Arrival Time Burst Time Completion Time Turnaround Time Waiting Time
P1 0 6 6 6 0
P2 1 8 14 13 5
P3 2 7 21 19 12

Gantt Chart:

P1 | P2 | P3

0 6 14 21

Average Times:

Average Turnaround Time = (6 + 13 + 19) / 3 = 12.67

Average Waiting Time = (0 + 5 + 12) / 3 = 5.67

Exercise 2: Shortest Job Next (SJN)

Processes: P1 (Arrival: 0, Burst: 5), P2 (Arrival: 1, Burst: 3), P3 (Arrival: 2, Burst: 2)

Calculations:

Process Arrival Time Burst Time Completion Time Turnaround Time Waiting Time
P1 0 5 10 10 5
P2 1 3 13 12 9
P3 2 2 15 13 11

Gantt Chart:

P1 | P2 | P3

0 10 13 15

Average Times:

Average Turnaround Time = (10 + 12 + 13) / 3 = 11.67

Average Waiting Time = (5 + 9 + 11) / 3 = 8.33

Exercise 3: Round Robin (RR)

Processes: P1 (Arrival: 0, Burst: 10), P2 (Arrival: 1, Burst: 4), P3 (Arrival: 2, Burst: 6) with time quantum = 2

Calculations:

Process Arrival Time Burst Time Completion Time Turnaround Time Waiting Time
P1 0 10 22 22 12
P2 1 4 19 18 14
P3 2 6 20 18 12

Gantt Chart:

P1 | P2 | P3 | P1 | P2 | P3

0 2 4 6 8 10 12 14 16 18 20 22

Average Times:

Average Turnaround Time = (22 + 18 + 18) / 3 = 19.33

Average Waiting Time = (12 + 14 + 12) / 3 = 12.67

How to Calculate Waiting Time, Turnaround Time, and Completion Time

Definitions:

  • Completion Time (CT): The time at which a process completes its execution.
  • Turnaround Time (TAT): The total time taken from arrival to completion.
    TAT = CT - Arrival Time
  • Waiting Time (WT): The total time a process spends waiting in the ready queue.
    WT = TAT - Burst Time

Example Calculation Table:

Process Arrival Time Burst Time Completion Time Turnaround Time Waiting Time
P1 0 6 6 6 - 0 = 6 6 - 6 = 0
P2 1 8 14 14 - 1 = 13 13 - 8 = 5
P3 2 7 21 21 - 2 = 19 19 - 7 = 12

No comments:

Post a Comment

Difference between File and Folder

10 Differences Between Files and Folders Definition: File: A collection of data or information stored on a computer. ...