Batch System Scheduling is a type of process scheduling used primarily in batch processing systems, where jobs (processes) are collected in batches, and the system executes them without user interaction.
- It is efficient for systems where job response time isn’t critical, as jobs can be processed without requiring immediate output or interaction.
Three common scheduling algorithms for batch systems are:
- First-Come, First-Served (FCFS)
- Shortest Job First (SJF
- Shortest Remaining Time Next (SRTN).
Note: In case of non-preemptive algorithm response time (RT) is calculated by subtracting Start Time−Arrival Time. But it is always equal to Waiting Time (WT).
Similarly, In case of preemptive algorithm response time (RT) is calculated by subtracting Start Time−Arrival Time. But it is not equal to Waiting Time (WT).
1.) First-Come, First-Served (FCFS)
FCFS is the simplest scheduling algorithm. Processes are executed in the order they arrive in the queue. The first process in the queue is served first, and each process completes before the next process starts. It’s a non-preemptive algorithm, meaning once a process starts executing, it cannot be interrupted until it completes.
Characteristics:
- Non-preemptive: A running process is not interrupted.
- Easy to implement and understand.
- May lead to the convoy effect: A long process can delay all others, increasing average waiting time.
In case of First-Come, First-Served, response time (RT) is calculated by subtracting Start Time−Arrival Time. But it is always equal to Waiting Time (WT).
Example:
2.) Shortest Job First (SJF)
SJF, also called Shortest Job Next (SJN), is a scheduling algorithm that selects the job with the smallest execution time (burst time) for execution next.
- It’s a non-preemptive algorithm, meaning once a job starts, it runs to completion. SJF is optimal for minimizing the average waiting time, as shorter jobs don’t wait long for longer jobs to finish.
Characteristics:
- Non-preemptive: Once a job starts, it completes before the next job is selected.
- Optimal in terms of average waiting time (lowest among all algorithms), but only if all jobs arrive at the same time.
- Requires knowing or estimating the burst time of each job.
In case of Shortest Job First, response time (RT) is calculated by subtracting Start Time−Arrival Time. But it is always equal to Waiting Time (WT).
Example:
3.) Shortest Remaining Time Next (SRTN)
Shortest Remaining Time Next (SRTN) is the preemptive version of Shortest Job First. In SRTN, the job with the smallest remaining execution time (burst time) is chosen for execution, even if it means preempting a currently running job. This ensures that short jobs are completed faster, providing an optimal response time.
- It is also known as shortest remaining time first (SRTF).
- In case of Shortest Remaining Time Next (SRTN), response time (RT) is calculated by subtracting Start Time−Arrival Time.
Characteristics:
- Preemptive: If a new job with a shorter remaining time arrives, it interrupts the currently running job.
- Optimal for minimizing average waiting time and response time.
- Requires continuous knowledge or estimation of remaining time for all jobs.
Example:
Important Note:
- Response Time=Start Time−Arrival Time
- eg: P1 starts at 0 and its arrival time is also 0, So RT is 0-0 = 0.