How to Draw a Gantt Chart for Preemptive SJF: 5-Step Guide
A preemptive SJF Gantt chart can feel confusing because the running process may change whenever a shorter job arrives. One missed arrival time can shift every later segment and leave your waiting-time calculations wrong.
But here's the truth: you can build the chart by tracking each process’s remaining burst time at every arrival or completion. You do not need to redraw the schedule at every time unit unless your instructor requests that level of detail.
Here’s a practical five-step method, followed by a worked example you can check. You’ll see when to interrupt a process, how to label each time boundary, and how to calculate turnaround and waiting times. Let me explain: once you focus on remaining time instead of original burst time, the schedule becomes much easier to follow.
How to draw a Gantt chart for preemptive SJF in 5 steps
Preemptive shortest-job-first (SJF) always runs the arrived process with the shortest remaining burst time. When a new process arrives with a shorter remaining time than the running process, the CPU preempts the current process and switches to the newcomer.
This policy is also called shortest remaining time first (SRTF). Use these five steps to build its Gantt chart.
Step 1: List each process, arrival time, and burst time
Write down every process with its arrival time and total CPU burst time. Arrival time tells you when a process becomes available; burst time tells you how much CPU time it needs overall.
For example, if P2 arrives at time 1 with a burst of 4, it cannot run before time 1. Once it starts, its remaining time decreases as it receives CPU time.
Step 2: Start at the earliest arrival time
Find the earliest arrival. If a process is available then, choose the one with the shortest burst time. If no process has arrived yet, mark the CPU as idle until the next arrival.
At the beginning of the schedule, each available process has its full burst time remaining. Later, compare processes using their remaining times, not their original bursts.
Step 3: Check the schedule at each arrival or completion
Move forward to the next event: a new process arriving or the running process finishing. At that point, compare the remaining time of every arrived, unfinished process.
Keep running the current process if it still has the shortest remaining time. Preempt it only when another available process has a shorter remaining time.
Step 4: Draw a new segment when the running process changes
Label each chart segment with the process running during that interval. Put a time boundary wherever the process changes, a process arrives and causes preemption, or the current process completes.
You may mark an arrival even when it does not cause a switch, especially if your course expects every event to appear. State your tie-breaking rule clearly when two processes have equal remaining times.
Step 5: Continue until every process finishes
Repeat the comparison until all processes have completed. Then use each process’s completion time to calculate turnaround time and waiting time.
A quick check helps catch mistakes: the total time assigned to each process across all its chart segments must equal its original burst time.
How preemptive SJF makes scheduling decisions
At any moment, SRTF compares the remaining burst times of all arrived processes that have not finished. The smallest value gets the CPU. An arrival does not automatically cause preemption; it matters only if the arriving process has less remaining work than the current one.
For instance, suppose P1 has 6 units left when P2 arrives with a burst of 8. P1 keeps running because 6 is shorter than 8. If P2 instead arrives with a burst of 3, P2 takes the CPU.
You might be wondering: what happens when two processes tie? Apply the rule given by your class or assignment. A common choice is to favor the earlier arrival, then keep the current process when the tie remains unresolved. Record your choice because another valid tie rule can change the chart’s process order.
Worked example: build the chart one event at a time
Use this small process set. It includes several arrivals while another process is running, so you can see how preemption works in practice.
| Process | Arrival time | Burst time |
|---|---|---|
| P1 | 0 | 8 |
| P2 | 1 | 4 |
| P3 | 2 | 2 |
| P4 | 3 | 1 |
Trace arrivals and remaining times
At time 0, P1 is the only available process, so it runs. By time 1, it has used one unit and has 7 remaining. P2 arrives with 4, so P2 preempts P1.
At time 2, P2 has 3 remaining when P3 arrives with 2. P3 takes over. At time 3, P3 has 1 remaining and P4 arrives with 1. They tie, so this example favors the earlier arrival, P3.
P3 finishes at time 4. P4 then runs from 4 to 5. P2 has 3 remaining, while P1 has 7, so P2 runs next and finishes at time 8. P1 completes the schedule at time 15.
Read the finished Gantt chart
| Time interval | Process running |
|---|---|
| 0–1 | P1 |
| 1–2 | P2 |
| 2–4 | P3 |
| 4–5 | P4 |
| 5–8 | P2 |
| 8–15 | P1 |
To sketch it, draw a horizontal bar divided into six adjoining segments. Label each segment with its process, then write the boundary times in order: 0, 1, 2, 4, 5, 8, and 15.
Calculate completion, turnaround, and waiting times
The final time boundary for a process’s last segment is its completion time. Turnaround time measures the full time between arrival and completion. Waiting time measures how long the process spent ready but not running.
Use these formulas:
- Turnaround time = completion time − arrival time
- Waiting time = turnaround time − burst time
- Response time = first start time − arrival time
For the worked example, P2 completes at time 8. Its turnaround time is 8 − 1 = 7, and its waiting time is 7 − 4 = 3. P4 completes at time 5, giving a turnaround time of 2 and a waiting time of 1.
| Process | Completion time | Turnaround time | Waiting time |
|---|---|---|---|
| P1 | 15 | 15 | 7 |
| P2 | 8 | 7 | 3 |
| P3 | 4 | 2 | 0 |
| P4 | 5 | 2 | 1 |
The average waiting time is (7 + 3 + 0 + 1) ÷ 4 = 2.75 time units. The average turnaround time is (15 + 7 + 2 + 2) ÷ 4 = 6.5 time units.
These values provide a useful check, but they do not replace checking the chart. If a process receives more or less CPU time than its burst, revisit the timeline before trusting the averages.
Common mistakes that distort the chart
Comparing original burst times after preemption: A process that has already run has less work remaining. Update its remaining time after every segment before choosing the next process.
Switching at every arrival automatically: An arrival only changes the schedule when the new process has a shorter remaining time. Compare values before drawing a new segment.
Forgetting a process’s earlier CPU time: A preempted process resumes with its remaining burst, not its full original burst. In the example, P2 returns at time 5 with 3 units left.
Leaving tie rules unstated: Equal remaining times can produce different valid segment orders. Follow the rule assigned in your course, or state the rule you chose beside the chart.
Mixing up waiting and turnaround: Turnaround includes CPU execution time and waiting. Subtract burst time from turnaround to find waiting time.
ONES.com for coordinating project work around schedules

Value proposition
Drawing an SRTF chart is a CPU scheduling exercise; ONES.com is a project and knowledge management platform for teams coordinating real work. Its separate products, ONES Project and ONES Wiki, can help teams organize plans and keep working guidance accessible.
The platform is powered by ONES Assistant. Teams can use cloud or self-hosted deployment options, including On-Premise, Private Cloud, and air-gapped environments.
Core capabilities
- Scattered project plans → ONES Project provides Jira-compatible workflows → teams can coordinate work in a familiar structure.
- Unclear task ownership → configurable workflows and fields → teams can make responsibilities and progress easier to track.
- Limited visibility into delivery → built-in reporting → project leads can review status without assembling separate progress summaries.
- Repeated manual coordination → automation features → teams can reduce recurring administrative steps.
- Unpredictable iteration planning → sprint management → teams can organize work into planned delivery cycles.
- Separate project and knowledge practices → ONES Project and ONES Wiki offer project management and knowledge management → teams can choose the product that fits each need.
- Plugin-heavy configurations → native capabilities and feature parity across cloud and self-hosted versions → teams can rely on built-in functions while selecting a suitable deployment.
- Small teams evaluating the platform → the free plan supports up to 30 seats → teams can try project coordination before expanding.
ONES Project is a Jira alternative for project management. ONES Wiki is a Confluence alternative for knowledge management. They are sold separately, so a team can select either product or use both where appropriate.
Application scenarios
Software team planning a sprint: A project lead can use ONES Project to manage tasks, configure a workflow, and review progress through built-in reporting. The team can keep sprint work visible without treating a CPU scheduling chart as a project plan.
Operations team working in a restricted environment: An organization with deployment requirements can evaluate Cloud, On-Premise, Private Cloud, or air-gapped deployment. Full feature parity between cloud and self-hosted versions gives teams flexibility when choosing where to run the platform.
Team organizing practical guidance: A team can use ONES Wiki to maintain knowledge articles while managing delivery work in ONES Project. Since the products are sold separately, teams can adopt the combination that matches their needs.
Common challenges when drawing an SRTF chart
A new arrival appears while you are calculating
Problem: You may continue a process past an arrival that should have changed the schedule. Solution: Recheck the available processes at every arrival and compare their remaining times before moving forward.
Several processes have the same remaining time
Problem: Different tie choices can produce different-looking charts. Solution: Use the prescribed tie rule, then write it down. If no rule is given, choose a consistent method and explain it.
The chart looks right, but the averages do not
Problem: A missed burst unit can create incorrect completion and waiting times. Solution: Add each process’s scheduled segments and compare the total with its original burst time. Then recalculate turnaround and waiting from the completion time.
The CPU is idle before the next arrival
Problem: A timeline can look incomplete if you jump directly to the next process. Solution: Draw an idle segment whenever no process is available. Label the interval so the elapsed time remains clear.
FAQs about preemptive SJF Gantt charts
Is preemptive SJF the same as shortest remaining time first?
Yes. Preemptive SJF is commonly called shortest remaining time first, or SRTF. Both names describe a scheduling policy that selects the arrived process with the least remaining CPU burst. When a newly arrived process has less remaining work than the running process, the CPU can switch to it.
When should I preempt the running process?
Check the schedule whenever a new process arrives. Compare the new process’s burst time with the running process’s remaining time and the remaining times of other available processes. Preempt only if another available process has a shorter remaining time. If the values tie, follow your stated tie-breaking rule.
Do I need to show every arrival on the chart?
Show a boundary whenever the running process changes or completes. You may also mark arrivals that do not cause a switch if your course requires every scheduling event to appear. In either case, check the process list at each arrival so you do not overlook a shorter job.
How do I find waiting time from a Gantt chart?
First find the completion time, then calculate turnaround time by subtracting arrival time. Subtract the original burst time from turnaround time to get waiting time. For a process arriving at 1, completing at 8, and requiring 4 CPU units, waiting time is (8 − 1) − 4 = 3.
Can two correct charts show different process orders?
They can when processes tie and the problem does not specify how to break ties. Different consistent rules may change the order of equal-time processes. State the rule you use and check that every process receives its full burst and finishes after its arrival.
Conclusion
To draw a preemptive SJF Gantt chart, list arrivals and bursts, track remaining times, and reconsider the schedule at every arrival or completion. Mark each process segment, apply a consistent tie rule, and use completion times to calculate turnaround and waiting.
The key is simple: compare remaining work, not original burst times, after a process has started. With that habit and a quick burst-time check, you can build a clear SRTF chart and verify the results with confidence.
For project teams managing schedules and ongoing work, ONES.com offers separate project and knowledge management products. Keep that distinction clear: an operating-system scheduling chart explains CPU allocation, while project tools help people coordinate tasks and team practices.