Shortest Job First SJF -CPU Scheduling
SHORTEST JOB FIRST (SJF) CPU SCHEDULING (NON-PREEMPTIVE)
1. AIM
To simulate the Shortest Job First (SJF) Non-Preemptive CPU Scheduling Algorithm using arrival time and burst time of processes and compute:
-
Completion Time (CT)
-
Turnaround Time (TAT)
-
Waiting Time (WT)
-
Average Waiting Time
2. THEORY
Shortest Job First Scheduling
SJF selects the process with the smallest burst time from the ready queue.
Characteristics
-
Non-preemptive: Once a process starts, it cannot be interrupted.
-
Minimizes average waiting time.
-
Not suitable for real-time systems because burst times must be known beforehand.
Key Performance Metrics
-
Completion Time (CT)
Time at which process finishes execution. -
Turnaround Time (TAT)
-
Waiting Time (WT)
3. ALGORITHM
-
Input number of processes n.
-
For each process, input:
-
Process ID
-
Arrival Time
-
Burst Time
-
-
At each step:
-
Select the process which has arrived and has smallest burst time.
-
Execute it to completion (non-preemptive).
-
-
For each process:
-
Compute CT, TAT, WT
-
-
Compute Average Waiting Time.
-
Display results.
4. C PROGRAM – SJF (Non-Preemptive) Using Structures
5. SAMPLE INPUT
6. GANTT CHART
7. SAMPLE OUTPUT
8. RESULT
The Shortest Job First (Non-Preemptive) scheduling algorithm was implemented successfully.
The program calculated:
-
Completion Time
-
Turnaround Time
-
Waiting Time
-
Average Waiting Time
for all processes according to SJF scheduling criteria.
Comments
Post a Comment