SREYAS INSTITUTE OF ENGINEERING & TECHNOLOGY
(AUTONOMUS)
(Approved by A.I.C.T.E.,New Delhi., Affiliated to JNTUH Hyderabad, Accredited by NAAC ‘A’ Grade & NBA)
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING(AI&ML)
Operating System
Project on
Implementation of CPU scheduling shortest Job
First algorithm (preemptive)
Presented by
[Link]-24VE1A6606
[Link] Chandana-24VE1A6612
[Link]-24VE1A6633
[Link]-24VE1A6650
21/11/2025 Implementation of CPU Scheduling 1
Abstract
Efficient CPU scheduling improves system performance by
managing process execution [Link] project implements
the preemptive Shortest Job First (SJF) algorithm, also known
as Shortest Remaining Time First (SRTF).The CPU always
selects the process with the shortest remaining burst time,
allowing interruptions when a shorter job [Link]
parameters include arrival time and burst time for each
[Link] scheduling generates output metrics such as waiting
time, turnaround time, and Gantt chart [Link]
show reduced average waiting time and better throughput
compared to non-preemptive [Link], the algorithm
may suffer from starvation of long processes due to continuous
arrival of shorter jobs.
21/11/2025 Implementation on CPU Scheduling 2
•Start Algorithm
•Initialize:
•Time = 0
•Completed = 0
•For each process, remaining_time[i] = burst_time[i]
•While Completed ≠ total number of processes:
[Link] all processes that have arrival time ≤ current time and not completed,
select the process with the minimum remaining time
[Link] no process is available, increment time++ and continue
[Link] CPU to the selected process for 1 time unit
[Link] its remaining_time by 1
[Link] remaining_time becomes 0:
•Mark process as completed
•completion_time[i] = current_time + 1
•turnaround_time[i] = completion_time[i] – arrival_time[i]
•waiting_time[i] = turnaround_time[i] – burst_time[i]
•Increment Completed++
[Link] time = time + 1
•Calculate average WT and TAT
•Stop
21/11/2025 Implementation of CPU scheduling 3
Block Diagram
21/11/2025 Implementation of CPU Scheduling 4
Code
21/11/2025 Implementation on CPU Scheduling 5
OUTPUT
21/11/2025 Implementation of CPU Scheduling 9
Advantages
1. Optimal for Minimizing Average Waiting Time
SRTF provides the minimum average waiting time among all CPU scheduling algorithms,
because it always executes the job with the smallest remaining time first.
2. Better Response for Short Processes
Small or short tasks are executed quickly, improving system responsiveness for interactive
applications.
3. Efficient CPU Utilization
By always keeping the CPU busy with the shortest remaining task, the overall CPU utilization
tends to be high.
4. Reduces Turnaround Time
Since short jobs finish earlier, the average turnaround time of the system becomes lower.
5. Supports Real-Time Environments
SRTF is suitable for soft real-time systems where quick responses are required for short-time
tasks.
21/11/2025 Implementation of CPU Scheduling 10
Applications
1. Operating Systems (Process Scheduling)
Used in OS kernels to decide which process should run next when
priority is based on burst time (especially older systems).
2. Batch Processing Systems
Ideal where jobs with predictable execution times arrive frequently.
Helps improve throughput in batch-style execution.
3. Embedded & Real-Time Systems
Applied in systems where:
Tasks have known short execution times
Quick responses are required
Examples: industrial controllers, small devices, sensor scheduling.
4. Cloud Computing & Resource Optimization
SRTF-like techniques are used to reduce job latency in cloud systems
where short tasks need fast execution.
Conclusion
• SJF Preemptive (SRTF) efficiently reduces average
waiting and turnaround time.
• It improves system responsiveness by prioritizing
shorter remaining tasks.
• The algorithm ensures better CPU utilization and faster
completion of short processes.
• However, it may cause starvation for long processes
and needs accurate burst-time prediction.
• Overall, SRTF is highly effective for systems requiring
quick task execution and optimal performance.
21/11/2025 Implementation of CPU Scheduling 12