[EdCert previous] [EdCert next] [EdCert top]

Batch processing and Unix scheduling priorities

Batch processing is simply instructing a system to execute commands from a list or queue. There are many types of batch systems available. Some are included with most Unix systems, others may be added to the Unix environment from the public domain or from commercial vendors.

Batch processing systems are implemented by system administrators of Unix super computers to share the computing resource of the system between many users and by system administrators of research sites to leverage the processing resources of many networked Unix systems.

A Unix system using batch processing can be made to perform CPU or memory intensive tasks late at night and early in the morning thus freeing the system for interactive use during normal business hours.

Additionally, the priority of a batch process or job can be set to be run only when the CPU is not busy. The priority is set with the nice command.


Unix batch processing

The heart of a batch processing system is the queuing mechanism of the program that is to be run. The file queuedefs is used to describe the characteristics of the queues managed by cron daemon. The file uses a letter between "a" and "y" to uniquely define the name of a queue. Tasks that are started by the at command are placed in the default queue for a. Those started by the batch command are placed in the b queue and the c queue is for tasks from the crontab file. The other queue names may be defined by users.

The at command uses the facilities of the cron daemon to schedule the execution of a script at a specified time. at does not do true batch processing, because many jobs may be scheduled to execute a the same time instead of having a queue of jobs to be executed with each job running in succession. The standard usage for the at command is:

$ at 1440 May 31
at> date
at> ^D 
warning: commands will be executed using /bin/csh
job 833571600.a at Fri May 31 14:40:00 1996

This causes the creation of a the file, /var/spool/cron/atjobs/833571600.a on this example host which is SunOS 5.x. Once the job has run this file is removed.

Other batch processing software

The optional Batch Queuing Systems page describes both public domain and from commercial vendors are described in detail.

Also optional, is a third party application, the Load Sharing Facility which is available for most Unix systems.

Unix Scheduling Priorities

Unix processes have an associated system nice value which is used by the kernel to determine when it should be scheduled to run. This value can be increased to facilitate processes executing quickly or decreased so that the processes execute slowly and thus do not interfere with other system activities.

The process scheduler, which is part of the Unix kernel, keeps the CPU busy by allocating it to the highest priority process. The nice value of a process is used to calculate the scheduling priority of a process. Other factors that are taken into account when calculating the scheduling priority for a process include the recent CPU usage and its process state, for example "waiting for I/O" or "ready to run".

Normally, processes inherit the system nice value of their parent process. At system initialization time, the system executes the init process with a system nice value of 20, this is the system default priority. All processes will inherit this priority unless this value is modified with the command nice. The nice value of 0 establishes an extremely high priority, whereas a value of 39 indicates a very low priority on SVR4 derived systems. On BSD derived systems scheduling priorities range from 0 to 127. The higher the value, the lower the priority, and the lower the value, the higher the priority.

There are two versions of nice; one that is built in to the C shell and the standalone nice command which is available to other shell users. Only the nice command will be described here. Refer to the man page for more information on the nice available to C shell users.

On systems derived from BSD, the nice command uses the numbers -20 to 20 to indicate the priorities, where 20 is the lowest and -20 is the highest. Any user can lower the priority of their processes, however only superuser and increase the priority of a job. To decrease the priority:

# nice -6 mybigjob
To increase the priority:
# nice --6 mybigjob

The nice levels for SVR4 systems are from 0 to 39. The default is 20. To decrease the priority:

# nice -6 mybigjob
In this example the level has been set to 20-6, or 14.
To increase the priority:
# nice +6 mybigjob
In this example the level has been set to 20+6, or 26.
Terms used: queue, scheduling, task scheduling.

[EdCert previous] [EdCert next] [EdCert top]