Skip to content
Related Articles

Related Articles

Gang scheduling in Operating System
  • Last Updated : 17 Mar, 2021

Scheduling is the process of managing resources (mostly hardware resources like I/O, CPU, memory, etc.) effectively to complete a given set of tasks. Most of the methods of scheduling are process scheduling like First Come First Serve (FCFS), Shortest Job First (SJF), Round Robin (RR), etc. There are many tasks that require multiple processes or threads to work concurrently with each other–only one process working while others wait will jeopardize the system. Even executing one process and preemptive stop on the other can also result in jeopardizing the system. 

What is a task ?

A Task is the smallest logical unit of work. A task can be made of multiple jobs. A job can a sub-task (similar to a task) or a process. All the jobs must work as a chunk in a specific order to complete a task. The jobs may be expected to run parallel or sequentially or a mix of both. 

For example–Turning on a car. The driver must press clutch and brake, and then turn the key. All three processes must happen or else the car won’t start. In computer science, we can find a similar example in a neural network; weights of all the edges must be updated in one segment.

What is a gang ?



A gang means a task. So, gang scheduling is the scheduling of gangs in an efficient manner. The point which separates gang scheduling from other scheduling is that it considers a gang (task) as a quantum and schedules them. A gang might require either multiple processes or threads or a combination of both (threads and processes).

Gang scheduling uses an Outsterhout matrix as a data structure to facilitate all the scheduling tasks. It is a two-dimensional matrix where a row represents a time slice and a column represents a process or a thread. 

 P1P2P3P4P5
Time Slice 0J1J1J1J1J1
Time Slice 1J2J2J2J2J2
Time Slice 2J3J3J4J4J4

The above table demonstrates how the Outsterhout matrix is formed and the jobs are scheduled. J1-J4 represents gangs and P1-P5 represents processes. Please note some literature also has processes in rows and time slices as columns. 

As gang scheduling includes multiple processes and threads, there is a need for synchronization. Broadly there are two synchronization methods.

  1. Concurrent gang scheduling: The synchronization module orchestrates all the scheduling. All the gangs run for a specific time interval ‘t’ then it is interpreted and another gang can begin.
  2. SHARE scheduling system: Gangs with the same resource utilization are collected and executed for a fixed time period. The fixed period may change each time and the time is greater than equal to the minimum time of the tasks till which they can be non-preemptive.

Like process scheduling there are various types of scheduling gangs namely:

  1. Bag of gangs (BoG)
  2. Adapted first come first served (AFCFS)
  3. The largest gang first-served (LGFS)
  4. Paired gang scheduling
  5. Scheduling algorithm

Further details on gang scheduling types can be found at the LINK.

My Personal Notes arrow_drop_up
Recommended Articles
Page :