The Wayback Machine - https://web.archive.org/web/20241118125613/https://www.geeksforgeeks.org/bankers-algorithm-in-operating-system/
Open In App

Banker’s Algorithm in Operating System

Last Updated : 05 May, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Prerequisite – Resource Allocation Graph (RAG), Banker’s Algorithm, Program for Banker’s Algorithm 
Banker’s Algorithm is a resource allocation and deadlock avoidance algorithm. This algorithm test for safety simulating the allocation for predetermined maximum possible amounts of all resources, then makes an “s-state” check to test for possible activities, before deciding whether allocation should be allowed to continue.

In simple terms, it checks if allocation of any resource will lead to deadlock or not, OR if is it safe to allocate a resource to a process and if not then resource is not allocated to that process. Determining a safe sequence(even if there is only 1) will assure that system will not go into deadlock.

Banker’s algorithm is generally used to find if a safe sequence exist or not. But here we will determine the total number of safe sequences and print all safe sequences.

How does the Banker’s Algorithm work?
The Banker’s Algorithm works by maintaining a matrix of resources and processes. Each row represents a process, and each column represents a resource. The matrix contains information about the current state of the system, including the maximum number of resources each process needs, the number of resources currently allocated to each process, and the number of resources available in the system.

: What is the purpose of the Banker’s Algorithm?
A: The purpose of the Banker’s Algorithm is to prevent deadlock, a situation where two or more processes are blocked, waiting for each other to release resources they need in order to proceed. Deadlock can cause a system to become unresponsive and may require a reboot to recover.

The data structure used are: 

  • Available vector
  • Max Matrix
  • Allocation Matrix
  • Need Matrix

Example:
Input: 


 

Output: Safe sequences are:
P2--> P4--> P1--> P3
P2--> P4--> P3--> P1
P4--> P2--> P1--> P3
P4--> P2--> P3--> P1

There are total 4 safe-sequences 

Explanation: 

Total resources are R1 = 10, R2 = 5, R3 = 7 and allocated resources are R1 = (0+2+3+2 =) 7, R2 = (1+0+0+1 =) 2, R3 = (0+0+2+1 =) 3. Therefore, remaining resources are R1 = (10 – 7 =) 3, R2 = (5 – 2 =) 3, R3 = (7 – 3 =) 4. 
Remaining available = Total resources – allocated resources 
and 
Remaining need = max – allocated
 

So, we can start from either P2 or P4. We can not satisfy remaining need from available resources of either P1 or P3 in first or second attempt step of Banker’s algorithm. There are only four possible safe sequences. 

These are : 
            P2--> P4--> P1--> P3 
            P2--> P4--> P3--> P1 
            P4--> P2--> P1--> P3 
            P4--> P2--> P3--> P1

Implementation:

C++




// C++ Program to Print all possible safe sequences using banker's algorithm
#include <iostream>
#include <string.h>
#include <vector>
// total number of process
#define P 4
// total number of resources
#define R 3
 
// total safe-sequences
int total = 0;
 
using namespace std;
 
// function to check if process
// can be allocated or not
bool is_available(int process_id, int allocated[][R],
                  int max[][R], int need[][R], int available[])
{
 
    bool flag = true;
 
    // check if all the available resources
    // are less greater than need of process
    for (int i = 0; i < R; i++) {
 
        if (need[process_id][i] > available[i])
            flag = false;
    }
 
    return flag;
}
 
// Print all the safe-sequences
void safe_sequence(bool marked[], int allocated[][R], int max[][R],
                   int need[][R], int available[], vector<int> safe)
{
 
    for (int i = 0; i < P; i++) {
 
        // check if it is not marked
        // already and can be allocated
        if (!marked[i] && is_available(i, allocated, max, need, available)) {
 
            // mark the process
            marked[i] = true;
 
            // increase the available
            // by deallocating from process i
            for (int j = 0; j < R; j++)
                available[j] += allocated[i][j];
 
            safe.push_back(i);
            // find safe sequence by taking process i
            safe_sequence(marked, allocated, max, need, available, safe);
            safe.pop_back();
 
            // unmark the process
            marked[i] = false;
 
            // decrease the available
            for (int j = 0; j < R; j++)
                available[j] -= allocated[i][j];
        }
    }
 
    // if a safe-sequence is found, display it
    if (safe.size() == P) {
 
        total++;
        for (int i = 0; i < P; i++) {
 
            cout << "P" << safe[i] + 1;
            if (i != (P - 1))
                cout << "--> ";
        }
 
        cout << endl;
    }
}
 
// Driver Code
int main()
{
 
    // allocated matrix of size P*R
    int allocated[P][R] = { { 0, 1, 0 },
                            { 2, 0, 0 },
                            { 3, 0, 2 },
                            { 2, 1, 1 } };
 
    // max matrix of size P*R
    int max[P][R] = { { 7, 5, 3 },
                      { 3, 2, 2 },
                      { 9, 0, 2 },
                      { 2, 2, 2 } };
 
    // Initial total resources
    int resources[R] = { 10, 5, 7 };
 
    // available vector of size R
    int available[R];
 
    for (int i = 0; i < R; i++) {
 
        int sum = 0;
        for (int j = 0; j < P; j++)
            sum += allocated[j][i];
 
        available[i] = resources[i] - sum;
    }
 
    // safe vector for displaying a safe-sequence
    vector<int> safe;
 
    // marked of size P for marking allocated process
    bool marked[P];
    memset(marked, false, sizeof(marked));
 
    // need matrix of size P*R
    int need[P][R];
    for (int i = 0; i < P; i++)
        for (int j = 0; j < R; j++)
            need[i][j] = max[i][j] - allocated[i][j];
 
    cout << "Safe sequences are:" << endl;
    safe_sequence(marked, allocated, max, need, available, safe);
 
    cout << "\nThere are total " << total << " safe-sequences" << endl;
    return 0;
}


Java




// Java Program to Print all possible safe
// sequences using banker's algorithm
import java.util.*;
 
public class GFG
{
 
    // total number of process
    static int P = 4;
     
    // total number of resources
    static int R = 3;
     
    // total safe-sequences
    static int total = 0;
 
    // function to check if process
    // can be allocated or not
    static boolean is_available(int process_id, int allocated[][],
                    int max[][], int need[][], int available[])
    {
 
        boolean flag = true;
 
        // check if all the available resources
        // are less greater than need of process
        for (int i = 0; i < R; i++)
        {
 
            if (need[process_id][i] > available[i])
            {
                flag = false;
            }
        }
 
        return flag;
    }
 
    // Print all the safe-sequences
    static void safe_sequence(boolean marked[], int allocated[][], int max[][],
                        int need[][], int available[], Vector<Integer> safe)
    {
 
        for (int i = 0; i < P; i++)
        {
 
            // check if it is not marked
            // already and can be allocated
            if (!marked[i] && is_available(i, allocated, max, need, available))
            {
 
                // mark the process
                marked[i] = true;
 
                // increase the available
                // by deallocating from process i
                for (int j = 0; j < R; j++)
                {
                    available[j] += allocated[i][j];
                }
 
                safe.add(i);
                 
                // find safe sequence by taking process i
                safe_sequence(marked, allocated, max, need, available, safe);
                safe.removeElementAt(safe.size() - 1);
 
                // unmark the process
                marked[i] = false;
 
                // decrease the available
                for (int j = 0; j < R; j++)
                {
                    available[j] -= allocated[i][j];
                }
            }
        }
 
        // if a safe-sequence is found, display it
        if (safe.size() == P)
        {
 
            total++;
            for (int i = 0; i < P; i++)
            {
 
                System.out.print("P" + (safe.get(i) + 1));
                if (i != (P - 1))
                {
                    System.out.print("--> ");
                }
            }
 
            System.out.println("");;
        }
    }
 
    // Driver Code
    public static void main(String[] args)
    {
         
        // allocated matrix of size P*R
        int allocated[][] = {{0, 1, 0},
        {2, 0, 0},
        {3, 0, 2},
        {2, 1, 1}};
 
        // max matrix of size P*R
        int max[][] = {{7, 5, 3},
        {3, 2, 2},
        {9, 0, 2},
        {2, 2, 2}};
 
        // Initial total resources
        int resources[] = {10, 5, 7};
 
        // available vector of size R
        int[] available = new int[R];
 
        for (int i = 0; i < R; i++)
        {
 
            int sum = 0;
            for (int j = 0; j < P; j++)
            {
                sum += allocated[j][i];
            }
 
            available[i] = resources[i] - sum;
        }
 
        // safe vector for displaying a safe-sequence
        Vector<Integer> safe = new Vector<Integer>();
 
        // marked of size P for marking allocated process
        boolean[] marked = new boolean[P];
 
        // need matrix of size P*R
        int[][] need = new int[P][R];
        for (int i = 0; i < P; i++)
        {
            for (int j = 0; j < R; j++)
            {
                need[i][j] = max[i][j] - allocated[i][j];
            }
        }
 
        System.out.println("Safe sequences are:");
        safe_sequence(marked, allocated, max, need, available, safe);
 
        System.out.println("\nThere are total " + total + " safe-sequences");
    }
}
 
/* This code contributed by PrinciRaj1992 */


Python3




# Python3 program to print all
# possible safe sequences
# using banker's algorithm
 
# Total number of process
P = 4
 
# Total number of resources
R = 3
  
# Total safe-sequences
total = 0
  
# Function to check if process
# can be allocated or not
def is_available(process_id, allocated,
                 max, need, available):
                      
    flag = True
  
    # Check if all the available resources
    # are less greater than need of process
    for i in range(R):
        if (need[process_id][i] > available[i]):
            flag = False
  
    return flag
 
# Print all the safe-sequences
def safe_sequence(marked, allocated,
                  max, need, available, safe):
     
    global total, P, R
     
    for i in range(P):
         
        # Check if it is not marked
        # already and can be allocated
        if (not marked[i] and
            is_available(i, allocated, max,
                         need, available)):
                              
            # mark the process
            marked[i] = True
  
            # Increase the available
            # by deallocating from process i
            for j in range(R):
                available[j] += allocated[i][j]
  
            safe.append(i)
             
            # Find safe sequence by taking process i
            safe_sequence(marked, allocated, max,
                          need, available, safe)
            safe.pop()
  
            # unmark the process
            marked[i] = False
  
            # Decrease the available
            for j in range(R):
                available[j] -= allocated[i][j]
         
    # If a safe-sequence is found, display it
    if (len(safe) == P):
        total += 1
         
        for i in range(P):
            print("P" + str(safe[i] + 1), end = '')
            
            if (i != (P - 1)):
                print("--> ", end = '')
             
        print()
  
# Driver code       
if __name__=="__main__":
     
    # Allocated matrix of size P*R
    allocated = [ [ 0, 1, 0 ],
                  [ 2, 0, 0 ],
                  [ 3, 0, 2 ],
                  [ 2, 1, 1 ]]
  
    # max matrix of size P*R
    max = [ [ 7, 5, 3 ],
            [ 3, 2, 2 ],
            [ 9, 0, 2 ],
            [ 2, 2, 2 ] ]
  
    # Initial total resources
    resources = [ 10, 5, 7 ]
  
    # Available vector of size R
    available = [0 for i in range(R)]
     
    for i in range(R):
        sum = 0
         
        for j in range(P):
            sum += allocated[j][i]
  
        available[i] = resources[i] - sum
     
  
    # Safe vector for displaying a
    # safe-sequence
    safe = []
  
    # Marked of size P for marking
    # allocated process
    marked = [False for i in range(P)]
  
    # Need matrix of size P*R
    need = [[0 for j in range(R)]
               for i in range(P)]
     
    for i in range(P):
        for j in range(R):
            need[i][j] = (max[i][j] -
                    allocated[i][j])
     
    print("Safe sequences are:")
     
    safe_sequence(marked, allocated, max,
                  need, available, safe)
     
    print("\nThere are total " + str(total) +
          " safe-sequences")
 
# This code is contributed by rutvik_56


C#




// C# Program to Print all possible safe
// sequences using banker's algorithm
using System;
using System.Collections.Generic;
 
class GFG
{
 
    // total number of process
    static int P = 4;
     
    // total number of resources
    static int R = 3;
     
    // total safe-sequences
    static int total = 0;
 
    // function to check if process
    // can be allocated or not
    static Boolean is_available(int process_id,
                                int [,]allocated,
                                int [,]max, int [,]need,
                                int []available)
    {
        Boolean flag = true;
 
        // check if all the available resources
        // are less greater than need of process
        for (int i = 0; i < R; i++)
        {
 
            if (need[process_id, i] > available[i])
            {
                flag = false;
            }
        }
 
        return flag;
    }
 
    // Print all the safe-sequences
    static void safe_sequence(Boolean []marked,
                              int [,]allocated,
                              int [,]max, int [,]need,
                              int []available,
                              List<int> safe)
    {
        for (int i = 0; i < P; i++)
        {
 
            // check if it is not marked
            // already and can be allocated
            if (!marked[i] &&
                is_available(i, allocated, max,
                               need, available))
            {
 
                // mark the process
                marked[i] = true;
 
                // increase the available
                // by deallocating from process i
                for (int j = 0; j < R; j++)
                {
                    available[j] += allocated[i, j];
                }
 
                safe.Add(i);
                 
                // find safe sequence by taking process i
                safe_sequence(marked, allocated, max,
                               need, available, safe);
                safe.RemoveAt(safe.Count - 1);
 
                // unmark the process
                marked[i] = false;
 
                // decrease the available
                for (int j = 0; j < R; j++)
                {
                    available[j] -= allocated[i, j];
                }
            }
        }
 
        // if a safe-sequence is found,
        // display it
        if (safe.Count == P)
        {
            total++;
            for (int i = 0; i < P; i++)
            {
                Console.Write("P" + (safe[i] + 1));
                if (i != (P - 1))
                {
                    Console.Write("--> ");
                }
            }
            Console.WriteLine("");;
        }
    }
 
    // Driver Code
    public static void Main(String[] args)
    {
         
        // allocated matrix of size P*R
        int [,]allocated = {{0, 1, 0},
                            {2, 0, 0},
                            {3, 0, 2},
                            {2, 1, 1}};
 
        // max matrix of size P*R
        int [,]max = {{7, 5, 3},
                      {3, 2, 2},
                      {9, 0, 2},
                      {2, 2, 2}};
 
        // Initial total resources
        int []resources = {10, 5, 7};
 
        // available vector of size R
        int[] available = new int[R];
 
        for (int i = 0; i < R; i++)
        {
            int sum = 0;
            for (int j = 0; j < P; j++)
            {
                sum += allocated[j,i];
            }
 
            available[i] = resources[i] - sum;
        }
 
        // safe vector for displaying a safe-sequence
        List<int> safe = new List<int>();
 
        // marked of size P for marking
        // allocated process
        Boolean[] marked = new Boolean[P];
 
        // need matrix of size P*R
        int[,] need = new int[P,  R];
        for (int i = 0; i < P; i++)
        {
            for (int j = 0; j < R; j++)
            {
                need[i, j] = max[i, j] - allocated[i, j];
            }
        }
 
        Console.WriteLine("Safe sequences are:");
        safe_sequence(marked, allocated, max,
                       need, available, safe);
 
        Console.WriteLine("\nThere are total " +
                            total + " safe-sequences");
    }
}
 
// This code is contributed by Rajput-Ji


Javascript




// total number of process
const P = 4;
// total number of resources
const R = 3;
 
// total safe-sequences
let total = 0;
 
// function to check if process
// can be allocated or not
function is_available(process_id, allocated, max, need, available) {
  let flag = true;
 
  // check if all the available resources
  // are less greater than need of process
  for (let i = 0; i < R; i++) {
    if (need[process_id][i] > available[i]) {
      flag = false;
      break;
    }
  }
 
  return flag;
}
 
// Print all the safe-sequences
function safe_sequence(marked, allocated, max, need, available, safe) {
  for (let i = 0; i < P; i++) {
 
    // check if it is not marked
    // already and can be allocated
    if (!marked[i] && is_available(i, allocated, max, need, available)) {
 
      // mark the process
      marked[i] = true;
 
      // increase the available
      // by deallocating from process i
      for (let j = 0; j < R; j++)
        available[j] += allocated[i][j];
 
      safe.push(i);
      // find safe sequence by taking process i
      safe_sequence(marked, allocated, max, need, available, safe);
      safe.pop();
 
      // unmark the process
      marked[i] = false;
 
      // decrease the available
      for (let j = 0; j < R; j++)
        available[j] -= allocated[i][j];
    }
  }
 
  // if a safe-sequence is found, display it
  if (safe.length === P) {
    total++;
    let result = "";
    for (let i = 0; i < P; i++) {
      result += "P" + (safe[i] + 1);
      if (i !== P - 1) {
        result += "--> ";
      }
    }
    console.log(result);
  }
}
 
// allocated matrix of size P*R
const allocated = [
  [0, 1, 0],
  [2, 0, 0],
  [3, 0, 2],
  [2, 1, 1]
];
 
// max matrix of size P*R
const max = [
  [7, 5, 3],
  [3, 2, 2],
  [9, 0, 2],
  [2, 2, 2]
];
 
// Initial total resources
const resources = [10, 5, 7];
 
// available vector of size R
const available = [];
 
for (let i = 0; i < R; i++) {
  let sum = 0;
  for (let j = 0; j < P; j++) {
    sum += allocated[j][i];
  }
  available.push(resources[i] - sum);
}
 
// safe vector for displaying a safe-sequence
const safe = [];
 
// marked of size P for marking allocated process
let marked = new Array(P).fill(false);
 
// need matrix of size P*R
let need = new Array(P);
for (let i = 0; i < P; i++) {
need[i] = new Array(R);
for (let j = 0; j < R; j++) {
need[i][j] = max[i][j] - allocated[i][j];
}
}
 
console.log("Safe sequences are:");
 
safe_sequence(marked, allocated, max, need, available, []);
 
console.log(`\nThere are total ${total} safe-sequences`);
 
// This code is contributed by Prince Kumar


Output

Safe sequences are:
P2--> P4--> P1--> P3
P2--> P4--> P3--> P1
P4--> P2--> P1--> P3
P4--> P2--> P3--> P1

There are total 4 safe-sequences

Time complexity: O(P*R)

Auxiliary Space: O(P*R)

FAQ:

Q1: What are the advantages of using the Banker’s Algorithm?
Employing the Banker’s Algorithm has various benefits such as averting a state of deadlock and enabling every process to finish its execution seamlessly. This could aid in boosting the overall stability and dependability of the system.

Q2: What are the limitations of the Banker’s Algorithm?
The Banker’s Algorithm has certain limitations as it assumes resources to be fixed in number that may not be feasible in several circumstances. Additionally, the algorithm supposes that a process’s maximum resource requirements are known beforehand, which may not hold true every time.

Q3: What are some real-world examples of where the Banker’s Algorithm is used?
The Banker’s Algorithm finds widespread usage across operating systems, resource allocation systems, manufacturing control systems, and airline reservation systems.



Previous Article
Next Article

Similar Reads

Banker's Algorithm in Operating System
The Banker’s Algorithm is a resource allocation and deadlock avoidance algorithm that tests for safety by simulating the allocation for the predetermined maximum possible amounts of all resources, then makes an “s-state” check to test for possible activities, before deciding whether allocation should be allowed to continue. The Banker's Algorithm i
15+ min read
Program for Banker's Algorithm | Set 1 (Safety Algorithm)
The banker’s algorithm is a resource allocation and deadlock avoidance algorithm that tests for safety by simulating the allocation for the predetermined maximum possible amounts of all resources, then makes an “s-state” check to test for possible activities, before deciding whether allocation should be allowed to continue. The following Data struc
15+ min read
Banker’s Discount in General Aptitude
For a better understanding of Banker’s discount concept, consider the situation where if person P buys some goods from person Q, where the person P wants to buy the goods but he doesn't have enough cash with him, so P issues a bill of exchange at a credit of x months with the interest of Y%. So that person Q can go to the bank after x months and ge
3 min read
Sequence Step Algorithm in Operating System
A Discrete Event Simulation models operation of a system as a series of events in time. Each event occurs at a particular instant in time and between these instances the system is assumed to be unchanged. The Sequence Step Algorithm is implemented in a discrete event simulation system to maximize resource utilization. It allows development of resou
2 min read
Page Buffering Algorithm in Operating System
The Page Buffering Algorithm is used in Operating systems and Database Management Systems as a key method to streamline data access and minimize disc I/O operations. It is largely used in virtual memory systems, where data is kept on secondary storage (disc) and brought into main memory as needed. The Page Buffering Algorithm's primary goal is to r
7 min read
Most Frequently Used (MFU) Algorithm in Operating System
MFU Algorithm is a Page Replacement Algorithm in the Operating System that replaces the page accessed a maximum number of times in the past. If more than one page is accessed the same number of times, then the page which occupied the frame first will be replaced. Page ReplacementIt is a technique of replacing a data block (frame) of Main Memory wit
4 min read
Counting Based Page Replacement Algorithm in Operating System
Counting Based Page Replacement Algorithm replaces the page based on count i.e. number of times the page is accessed in the past. If more than one page has the same count, then the page that occupied the frame first would be replaced. Page Replacement: Page Replacement is a technique of replacing a data block (frame) of Main Memory with the data bl
5 min read
Deadlock Detection Algorithm in Operating System
In operating systems, managing resources like memory, files, and processors is very important. Sometimes, processes (or programs) get stuck waiting for each other to release resources, leading to a situation called a deadlock. To handle deadlocks, operating systems use special methods called deadlock detection algorithms. These algorithms help iden
7 min read
System Protection in Operating System
Introduction: System protection in an operating system refers to the mechanisms implemented by the operating system to ensure the security and integrity of the system. System protection involves various techniques to prevent unauthorized access, misuse, or modification of the operating system and its resources. There are several ways in which an op
3 min read
User View Vs Hardware View Vs System View of Operating System
User View of Operating System: The Operating System is an interface, hides the details which must be performed and present a virtual machine to the user that makes it easier to use. Operating System provides the following services to the user. Execution of a programAccess to I/O devicesControlled access to filesError detection (Hardware failures, a
1 min read
Xv6 Operating System -adding a new system call
Prerequisite - Xv6 Operating System -add a user program In last post we got to know how to add user program in Xv6 Operating System. Now here you will see how to add new system call in Xv6 Operating System. A dding new system call to xv6: A system call is way for programs to interact with operating system. A computer program makes system call when
6 min read
Traps and System Calls in Operating System (OS)
Traps and system calls are two mechanisms used by an operating system (OS) to perform privileged operations and interact with user-level programs. Here is an overview of each mechanism: Traps: A trap is an interrupt generated by the CPU when a user-level program attempts to execute a privileged instruction or encounters an error. When a trap occurs
3 min read
Fork System Call in Operating System
In many operating systems, the fork system call is an essential operation. The fork system call allows the creation of a new process. When a process calls the fork(), it duplicates itself, resulting in two processes running at the same time. The new process that is created is called a child process. It is a copy of the parent process. The fork syst
5 min read
System Programs in Operating System
System Programming can be defined as the act of building Systems Software using System Programming Languages. According to Computer Hierarchy, Hardware comes first then is Operating System, System Programs, and finally Application Programs. Program Development and Execution can be done conveniently in System Programs. Some of the System Programs ar
3 min read
File System Implementation in Operating System
A file is a collection of related information. The file system resides on secondary storage and provides efficient and convenient access to the disk by allowing data to be stored, located, and retrieved. File system implementation in an operating system refers to how the file system manages the storage and retrieval of data on a physical storage de
11 min read
Difference between System Software and Operating System
Software is like a set of instructions that tell a computer what to do. There are two main types application software and system software. Application software is extra programs you can add to your computer to do specific things, like write documents or play games. You don't need these to use your computer, but they help you do particular tasks. Sy
5 min read
Swap Space in Operating System
A computer has a sufficient amount of physical memory but most of the time we need more so we swap some memory on disk. Swap space is a space on a hard disk that is a substitute for physical memory. It is used as virtual memory which contains process memory images. Whenever our computer runs short of physical memory it uses its virtual memory and s
6 min read
Allocation of frames in Operating System
An important aspect of operating systems, virtual memory is implemented using demand paging. Demand paging necessitates the development of a page-replacement algorithm and a frame allocation algorithm. Frame allocation algorithms are used if you have multiple processes; it helps decide how many frames to allocate to each process. There are various
3 min read
Thread Models in Operating System
A thread is a light weight process which is similar to a process where every process can have one or more threads. Each thread contains a Stack and a Thread Control Block. There are four basic thread models : 1. User Level Single Thread Model : Each process contains a single thread.Single process is itself a single thread.process table contains an
2 min read
The Tempo Operating System
Operating system : An Operating system is an interface between the computer user and computer hardware. An Operating system is a software which performs all the basic task like file handling, file management, memory management, handling input and output, controlling peripherals devices such as disk drive and printer, mouse...etc Tempo operating sys
5 min read
Boot Block in Operating System
Basically for a computer to start running to get an instance when it is powered up or rebooted it need to have an initial program to run. And this initial program which is known as bootstrap needs to be simple. It must initialize all aspects of the system, from CPU registers to device controllers and the contents of the main memory, and then starts
5 min read
Comparison on using Java for an Operating System instead of C
Java is a managed language which offers memory safety. In Java, pointers do not exist, so we cannot do pointer arithmetic on a function pointer. An application can invoke a method defined in a class through the class object. In Java, we cannot do unsafe typecast of an object to overwrite the method pointer with something else. An out of bound array
2 min read
Difference between Loading and Linking in Operating System
An operating system acts as an intermediary between the user of a computer and computer hardware. The purpose of an operating system is to provide an environment in which a user can execute programs conveniently and efficiently. Linking and Loading are utility programs that play an important role in the execution of a program. Linking intakes the o
4 min read
Stack Implementation in Operating System uses by Processor
A stack is an associate ordered a set of components, only one of that (last added) are often accessed at a time. The point of access is named the highest of the stack. The number of components within the stack, or length of the stack, is variable. Items could solely be side to or deleted from the highest of the stack. For this reason, a stack is ad
4 min read
Best-Fit Allocation in Operating System
INTRODUCTION: Best-Fit Allocation is a memory allocation technique used in operating systems to allocate memory to a process. In Best-Fit, the operating system searches through the list of free blocks of memory to find the block that is closest in size to the memory request from the process. Once a suitable block is found, the operating system spli
4 min read
Thread Control Block in Operating System
Very similar to Process Control Blocks (PCBs) which represents processes, Thread Control Blocks (TCBs) represents threads generated in the system. It contains information about the threads, such as it's ID and states. The components have been defined below: Thread ID: It is a unique identifier assigned by the Operating System to the thread when it
1 min read
Two State Process Model in Operating System
Pre-requisite: States of a Process in Operating Systems The process in an operating system passes from different states starting from its formation to its completion. A process consists of program data and its associated data and a process control block (PCB). A process may change its state because of the following events like I/O requests, interru
3 min read
I/O Hardware in Operating System
I/O Hardware is a set of specialized hardware devices that help the operating system access disk drives, printers, and other peripherals. These devices are located inside the motherboard and connected to the processor using a bus. They often have specialized controllers that allow them to quickly respond to requests from software running on top of
6 min read
Completely Fair Queuing (CFQ) in Operating System
Several Linux I/O schedulers have been proposed. Some of these are: Completely Fair Queuing (CFQ) Deadline NOOP Anticipatory CFQ is one of the input/output scheduler for the Linux kernel and is the current default scheduler in the Linux kernel. What is kernel ? Kernel is the central part of an operating system. It manages the operation between the
2 min read
Concurrent Processes in Operating System
Concurrent processing is a computing model in which multiple processors execute instructions simultaneously for better performance. Concurrent means, which occurs when something else happens. The tasks are broken into subtypes, which are then assigned to different processors to perform simultaneously, sequentially instead, as they would have to be
2 min read
Article Tags :
Practice Tags :
three90RightbarBannerImg