Category: Operating System

CPU Schedulers | Schedulers in OS | Schedulers

Schedulers in OS-

 

  • Schedulers in OS are special system software.
  • They help in scheduling the processes in various ways.
  • They are mainly responsible for selecting the jobs to be submitted into the system and deciding which process to run.

 

Types of Schedulers-

 

There are 3 kinds of schedulers-

 

 

  1. Long-term scheduler
  2. Short-term scheduler
  3. Medium-term scheduler

 

1. Long-term Scheduler-

 

The primary objective of long-term scheduler is to maintain a good degree of multiprogramming.

 

  • Long-term scheduler is also known as Job Scheduler.
  • It selects a balanced mix of I/O bound and CPU bound processes from the secondary memory (new state).
  • Then, it loads the selected processes into the main memory (ready state) for execution.

 

2. Short-term Scheduler-

 

The primary objective of short-term scheduler is to increase the system performance.

 

  • Short-term scheduler is also known as CPU Scheduler.
  • It decides which process to execute next from the ready queue.
  • After short-term scheduler decides the process, Dispatcher assigns the decided process to the CPU for execution.

 

3. Medium-term Scheduler-

 

The primary objective of medium-term scheduler is to perform swapping.

 

  • Medium-term scheduler swaps-out the processes from main memory to secondary memory to free up the main memory when required.
  • Thus, medium-term scheduler reduces the degree of multiprogramming.
  • After some time when main memory becomes available, medium-term scheduler swaps-in the swapped-out process to the main memory and its execution is resumed from where it left off.
  • Swapping may also be required to improve the process mix.

 

Comparison Of Schedulers-

 

Long-term scheduler Medium-term scheduler Short-term scheduler
It is a job scheduler It is a process swapping scheduler. It is a CPU scheduler
It controls the degree of multiprogramming. It reduces the degree of multiprogramming. It provides lesser control over degree of multiprogramming.
Speed is lesser than short-term scheduler Speed is in between the long-term and short-term schedulers. Speed is fastest among the other two.
It is minimal or almost absent in time sharing system. It is a part of time sharing system. It is also minimal in time sharing system.
It selects processes from new state and loads them into ready state. It swaps-out processes from main memory to secondary memory and later swaps in. It selects processes from the ready state and assigns to the CPU.
Operates less frequently since processes are not rapidly created. Operates more frequently than long-term scheduler but less frequently than short-term scheduler. Operates very frequently to match the speed of CPU since CPU rapidly switches from one process to another

 

Degree of Multiprogramming-

 

In multiprogramming systems,

  • Multiple processes may be present in the ready state which are all ready for execution.
  • Degree of multiprogramming is the maximum number of processes that can be present in the ready state.
  • Long-term scheduler controls the degree of multiprogramming.
  • Medium-term scheduler reduces the degree of multiprogramming.

 

Optimal Degree of Multiprogramming-

 

  • An optimal degree of multiprogramming means average rate of process creation is equal to the average departure rate of processes from main memory.
  • It is the responsibility of long-term scheduler to maintain a good degree of multiprogramming.

 

To gain better understanding about Schedulers in OS,

Watch this Video Lecture

 

Next Article- Various Times Of Process

 

Get more notes and other study material of Operating System.

Watch video lectures by visiting our YouTube channel LearnVidFun.

Batch Operating System | Types of Operating System

Types of Operating System-

 

The most popularly used types of operating system are-

 

 

  1. Batch Operating System
  2. Multiprogramming Operating System
  3. Multitasking Operating System
  4. Multiprocessing Operating System
  5. Real time Operating System

 

In this article, we will discuss about Batch Operating System.

 

Batch Operating System-

 

In batch operating system,

  • Firstly, user prepares his job using punch cards.
  • Then, he submits the job to the computer operator.
  • Operator collects the jobs from different users and sort the jobs into batches with similar needs.
  • Then, operator submits the batches to the processor one by one.
  • All the jobs of one batch are executed together.

 

 

Advantages-

 

  • It saves the time that was being wasted earlier for each individual process in context switching from one environment to another environment.
  • No manual intervention is needed.

 

Disadvantages-

 

Point-01:

 

Priority can not be set for the jobs.

 

In batch operating system,

  • All the jobs of a batch are executed sequentially one after the other.
  • The output is obtained only after all the jobs are executed.
  • Thus, priority can not be implemented if a certain job has to be executed on an urgent basis.

 

Point-02:

 

Batch operating system may lead to starvation.

 

In batch operating system,

  • The jobs of a particular batch might take long time for their execution.
  • This might lead to starvation to other jobs in other batches.

 

Point-03:

 

CPU may remain idle for a long time.

 

In batch operating system,

  • If the jobs of a batch require some I/O operation, then CPU must wait till the I/O operation gets completed.
  • Since I/O devices are very slow, CPU remains idle for a long time.
  • CPU can not take any other job and execute it.

 

Point-04:

 

There is a lack of interaction between a user and his job.

 

In batch operating system,

  • Once a batch is submitted for execution, the user is not able to interact with any of his jobs.
  • If a job requires the user to input data during run time, then user must wait till the other jobs of the batch get executed.
  • This also increases the overall execution time.

 

To gain better understanding about Batch Operating System,

Watch this Video Lecture

 

Next Article- Process States | Diagram

 

Get more notes and other study material of Operating System.

Watch video lectures by visiting our YouTube channel LearnVidFun.

Process Control Block | Process Attributes

Process Control Block-

 

  • Process Control Block (PCB) is a data structure that stores information about a particular process.
  • This information is required by the CPU while executing the process.

 

The Process Control Block of a process looks like-

 

 

  • Each process is identified by its own process control block (PCB).
  • It is also called as context of the process.

 

Process Attributes-

 

The various attributes of process stored in the PCB are-

 

1. Process Id-

 

  • Process Id is a unique Id that identifies each process of the system uniquely.
  • A process Id is assigned to each process during its creation.

 

2. Program Counter-

 

  • Program counter specifies the address of the instruction to be executed next.
  • Before execution, program counter is initialized with the address of the first instruction of the program.
  • After executing an instruction, value of program counter is automatically incremented to point to the next instruction.
  • This process repeats till the end of the program.

 

3. Process State-

 

  • Each process goes through different states during its lifetime.
  • Process state specifies the current state of the process.

 

Read more- Process States in OS

 

4. Priority-

 

  • Priority specifies how urgent is to execute the process.
  • Process with the highest priority is allocated the CPU first among all the processes.

 

5. General Purpose Registers-

 

  • General purpose registers are used to hold the data of process generated during its execution.
  • Each process has its own set of registers which are maintained by its PCB.

 

6. List of Open Files-

 

  • Each process requires some files which must be present in the main memory during its execution.
  • PCB maintains a list of files used by the process during its execution.

 

7. List of Open Devices-

 

  • PCB maintains a list of open devices used by the process during its execution.

 

Important Notes-

 

  • PCB of each process resides in the main memory.
  • There exists only one PCB corresponding to each process.
  • PCB of all the processes are present in a linked list.

 

To gain better understanding about Process Control Block,

Watch this Video Lecture

 

Next Article- Schedulers in OS

 

Get more notes and other study material of Operating System.

Watch video lectures by visiting our YouTube channel LearnVidFun.

Process States in Operating System

Process States in Operating System-

 

Each process goes through different states in its life cycle-

 

 

1. New State-

 

  • A process is said to be in new state when a program present in the secondary memory is initiated for execution.

 

2. Ready State-

 

  • A process moves from new state to ready state after it is loaded into the main memory and is ready for execution.
  • In ready state, the process waits for its execution by the processor.
  • In multiprogramming environment, many processes may be present in the ready state.

 

3. Run State-

 

  • A process moves from ready state to run state after it is assigned the CPU for execution.

 

4. Terminate State-

 

  • A process moves from run state to terminate state after its execution is completed.
  • After entering the terminate state, context (PCB) of the process is deleted by the operating system.

 

5. Block Or Wait State-

 

  • A process moves from run state to block or wait state if it requires an I/O operation or some blocked resource during its execution.
  • After the I/O operation gets completed or resource becomes available, the process moves to the ready state.

 

6. Suspend Ready State-

 

  • A process moves from ready state to suspend ready state if a process with higher priority has to be executed but the main memory is full.
  • Moving a process with lower priority from ready state to suspend ready state creates a room for higher priority process in the ready state.
  • The process remains in the suspend ready state until the main memory becomes available.
  • When main memory becomes available, the process is brought back to the ready state.

 

6. Suspend Wait State-

 

  • A process moves from wait state to suspend wait state if a process with higher priority has to be executed but the main memory is full.
  • Moving a process with lower priority from wait state to suspend wait state creates a room for higher priority process in the ready state.
  • After the resource becomes available, the process is moved to the suspend ready state.
  • After main memory becomes available, the process is moved to the ready state.

 

Important Notes-

 

Note-01:

 

A process necessarily goes through minimum 4 states.

 

  • The minimum number of states through which a process compulsorily goes through is 4.
  • These states are new state, ready state, run state and terminate state.
  • However, if a process also requires the I/O operation, then minimum number of states is 5.

 

Note-02:

 

A single processor can execute only one process at a time.

 

  • A single processor can not more than one processes simultaneously.
  • If n processors are present in the system, then only n processes can be executed simultaneously.

 

Note-03:

 

State Present in Memory
New state Secondary Memory
Ready state Main Memory
Run state Main Memory
Wait state Main Memory
Suspend wait state Secondary Memory
Suspend ready state Secondary Memory
Terminate state

 

Note-04:

 

Moving a process from wait state to suspend wait state is a better alternative.

 

  • Consider a process with higher priority arrives and the main memory is full.
  • Then, there are two ways to make room for it.

 

These two ways are-

  1. Moving a process with lower priority from ready state to suspend ready state.
  2. Moving a process with lower priority from wait state to suspend wait state.

 

Out of these-

  • Moving a process from wait state to suspend wait state is a better alternative.
  • This is because the process is already waiting for some blocked resource.

 

To gain better understanding about Process States in Operating System,

Watch this Video Lecture

 

Next Article- Process Control Block | PCB

 

Get more notes and other study material of Operating System.

Watch video lectures by visiting our YouTube channel LearnVidFun.