Batch Job Management
Batch jobs refer to a type of job that is automatically processed by the operating system without user intervention. The main purpose of batch jobs is to improve the efficiency of the system and reduce the idle time of the system and the waiting time of users by centrally processing a batch of jobs. Batch job management involves three main functions: job input, job scheduling, and job control.
Batch job input
Job input
- Definition: Load the jobs submitted by the user into the auxiliary storage input well (such as disk) and form a backup job queue. The system queues the jobs in the order in which they enter the input well for scheduling and execution.
- Job input information usually includes:
- Source program: Program code to be compiled and executed.
- Initial data: Input data required for program execution.
- Job control instructions: Instructions for describing the job execution steps, written in job control language.
Job control language (JCL)
- Definition: It is a programming language that describes the job execution process and is used in batch systems. Users specify the execution steps and required resources of the job through JCL.
- Function:
- Job submission: Describes the start and end of a job.
- Job and job step execution control: Specifies the execution order and dependencies of jobs.
- Resource usage control: Specifies the hardware and software resources required for job execution.
Job Control Block (JCB)
- Definition: The identification of a job in the system, including various attributes and status information of the job.
- Main content:
- Job name, job status
- Job priority, category
- Required resources (main memory, peripherals)
- Job time information (submission time, start time, end time)
- Purpose: Used by the system's input program, job scheduler, job control program, etc. to access job information.
Job table
- Definition: A collection of JCBs of all jobs, stored in auxiliary storage, used for system management and query of job information.
Batch job scheduling
Job scheduler
- Definition: A program used to control job scheduling, which selects appropriate jobs from the backup job queue for execution according to a certain scheduling algorithm.
- Main tasks:
- Select job: Select jobs from the backup job queue for execution.
- Resource allocation: Allocate necessary resources such as main memory and peripherals to the selected job.
- Prepare for execution: Create a job control block and process control block for the job and prepare for execution.
- Post-processing: When the job ends or is revoked, release resources and update the job status.
Job status
The status of a job in the system can be divided into the following types:
- Submission status: The job has just been submitted to the system and is waiting to enter the backup queue.
- Backup status: The job is waiting for scheduling in the input well.
- Running status: The job is selected by the scheduler and enters the execution state after resources are allocated.
- Completion status: The job is executed, resources are released, and the job exits the system.
Factors affecting job scheduling
- Fairness: Ensure that system resources are fairly distributed among users.
- Balanced use of resources: Rationally schedule jobs so that system resources are used in a balanced manner.
- Improve system throughput: Maximize the number of jobs completed per unit time.
- Balance system and user requirements: Take into account both system performance and user experience.
Performance indicators of job scheduling
- CPU utilization: The ratio of effective working time of the CPU to total time.
- Throughput: The number of jobs completed by the system per unit time.
- Turnaround time: The total time from when a job enters the system to when it is completed.
- Average turnaround time: The average turnaround time of all jobs.
\[
T = \frac{1}{n} \sum_{i=1}^{n} T_i
\]
T: Indicates the average turnaround time. n: Indicates the total number of jobs. \( T_{i} \): Indicates the turnaround time of the i-th job.
- Weighted average turnaround time: Consider the proportion of job execution time and give priority to short jobs.
\[
W = \frac{1}{n} \sum_{i=1}^{n} W_i
\]
W: indicates the average waiting time. n: indicates the total number of jobs. \( W_{i} \): indicates the waiting time of the i-th job.
Three-level scheduling of batch job scheduling
- High-level scheduling (job scheduling): select which jobs to enter the main memory from the backup queue for execution.
- Intermediate scheduling: control the number of processes in the main memory and balance memory usage by swapping in and out processes.
- Low-level scheduling (process scheduling): select processes in the ready queue to allocate CPU execution.
Batch job control
Execution of batch jobs
- Job execution process: when a job is selected by the scheduler, the system creates a job control process for it, which is responsible for specific job operation control.
- Operation control: The system executes each job step by step according to the job control instructions until the job is completed.
Termination and cancellation of batch jobs
- Job termination: When the job is successfully completed or an exception occurs, the system releases resources, updates the job status, and continues to schedule the next job.
- Job cancellation: When a serious error occurs or the user requests to terminate, the system forcibly stops the job execution and performs follow-up processing.