Gang scheduling in Operating System
Last Updated :
01 Nov, 2022
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 Ousterhout 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.
| P1 | P2 | P3 | P4 | P5 |
Time Slice 0 | J1 | J1 | J1 | J1 | J1 |
Time Slice 1 | J2 | J2 | J2 | J2 | J2 |
Time Slice 2 | J3 | J3 | J4 | J4 | J4 |
The above table demonstrates how the Ousterhout 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.
- 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.
- 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:
- Bag of gangs (BoG)
- Adapted first come first served (AFCFS)
- The largest gang first-served (LGFS)
- Paired gang scheduling
- Scheduling algorithm
Further details on gang scheduling types can be found at the LINK.
Similar Reads
I/O scheduling in Operating Systems Input/Output (I/O) operations are how a computer communicates with external devices such as hard drives, keyboards, printers, and network interfaces. These operations involve transferring data into and out of the system whether itâs reading a file, saving a document, printing, or sending data over a
6 min read
Batch Processing Operating System In the beginning, computers were very large types of machinery that ran from a console table. In all-purpose, card readers or tape drivers were used for input, and punch cards, tape drives, and line printers were used for output. Operators had no direct interface with the system, and job implementat
6 min read
Multi Processing Operating System The operating system functions like a manager of all the available resources. Therefore operating system is defined as an interface between the system and the user. There are various types of operating systems such as Batch Operating Systems, Multi-programming Operating Systems, distributed operatin
4 min read
Operating System Security Protection refers to a mechanism that controls the access of programs, processes, or users to the resources defined by a computer system. We can take protection as a helper to multiprogramming operating systems so that many users might safely share a common logical namespace such as a directory or f
8 min read
Cooperating Process in Operating System Pre-requisites: Process Synchronization In an operating system, everything is around the process. How the process goes through several different states. So in this article, we are going to discuss one type of process called as Cooperating Process. In the operating system there are two types of proce
2 min read
Resource Management in Operating System Resource Management in Operating System is the process to manage all  the resources efficiently like CPU, memory, input/output devices, and other hardware resources among the various programs and processes running in the computer. Resource management is an important thing because resources of a comp
3 min read