0% found this document useful (0 votes)
5 views

OS File1

Uploaded by

himanshu828383
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

OS File1

Uploaded by

himanshu828383
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

OS LAB FILE

 cd – change directory
 ls – list all the files/directories
 clear – used to clear the terminal
 exit – used to exit
 cat – displays the contents of the file
 cal & date – calendar and date & time commands respectively
SYSTEM CALL
fork() is used to create a new child process
getpid() is used to get ID of the parent thread
getppid() is used to get process ID of parent process
FCFS Algorithm
SJF Algorithm
Banker’s Algorithm

Memory Mangement
First Fit Algorithm

#include<iostream> using namespace std;

void firstFit(int blockSize[], int m,

int processSize[], int n)

{ int allocation[n]; for(int i=0;i<n;i++)

allocation[i]=-1;

for (int i = 0; i < n; i++)

for (int j = 0; j < m; j++)

if (blockSize[j] >= processSize[i])

{ allocation[i] = j; blockSize[j] -= processSize[i];

break;

cout << "\nProcess No.\tProcess Size\tBlock no.\n"; for (int i = 0; i < n; i++)

{ cout << " " << i+1 << "\t\t"

<< processSize[i] << "\t\t"; if (allocation[i] != -1)


cout << allocation[i] + 1;
else cout << "Not Allocated";

cout << endl;

int main()

{
int blockSize[] = {100, 500, 200, 300, 600}; int processSize[] = {212, 417, 112 ,
426}; int m = sizeof(blockSize) / sizeof(blockSize[0]); int n =
sizeof(processSize) / sizeof(processSize[0]); firstFit(blockSize, m, processSize,
n);

return 0 ;

You might also like