O.S Lab Programming
O.S Lab Programming
#include<iostream>
using namespace std;
struct process
{
int process_id;
int arrival_time;
int brust_time;
int completion_time;
int turnAround_time;
int waiting_time;
};
for(int i=0;i<n;i++)
{
cout<<arr[i].process_id<<"\t\t\t"<<arr[i].arrival_time<<"\t\t"<<arr[i].brust_time<<"\t\t"
<<arr[i].completion_time<<"\t\t"<<arr[i].turnAround_time<<"\t\t\t"<<arr[i].waiting_time<<endl;
}
}
int main()
{
int n=5;
process arr[n]={{1,4,3},{2,5,1},{3,9,6},{4,7,5},{5,8,3}};
findFCFS(arr,n);
printFCFS(arr,n);
Process No. Arrival Time Burst Time Completions Time TurnAround Time Waiting Time
1 4 3 3 -1 0
2 5 1 4 -1 -2
3 9 6 10 1 -5
4 7 5 15 8 3
5 8 3 18 10 7
#include<iostream>
using namespace std;
struct process
{
int process_no;
int arrival_time;
int burst_time;
int completion_time;
int turnAround_time;
int waiting_time;
};
}
int currentTime=0;
int complete=0;
int shortest =0;
int minBurst=9999;
while(complete<n)
{
minBurst=9999;
for(int i=0;i<n;i++)
{
if(arr[i].arrival_time<=currentTime && remaining_time[i]<minBurst &&
remaining_time[i]>0)
{
minBurst=remaining_time[i];
shortest=i;
}
}
remaining_time[shortest]--;
if(remaining_time[shortest]==0)
{
complete++;
arr[shortest].completion_time = currentTime+1;
arr[shortest].turnAround_time = arr[shortest].completion_time -
arr[shortest].arrival_time;
arr[shortest].waiting_time=arr[shortest].turnAround_time - arr[shortest].burst_time;
}
currentTime++;
}
}
for(int i=0;i<n;i++)
{
cout<<arr[i].process_no<<"\t\t"<<arr[i].arrival_time<<"\t"<<arr[i].burst_time<<"\t"
<<arr[i].completion_time<<"\t\t"<<arr[i].turnAround_time<<"\t\t"<<arr[i].waiting_time<<endl;
}
cout<<endl;
cout<<"Solved by : PtuCoder or Sahil Rauniyar !"<<endl;
int main()
{
int n=5;
process arr[n];
cout<<"ENter the process details (process id \t arrival time \t burst time :)"<<endl;
for(int i=0;i<n;i++)
{
cout<<"ENter the process :"<<endl;
cin>>arr[i].process_no>>arr[i].arrival_time>>arr[i].burst_time;
}
findSJF(arr,n);
printSJF(arr,n);
return 0;
OUTPUT ➖
ENter the process details (process id arrival time burst time :)
1 5 3 3 -2 -5
2 7 4 11 4 0
3 8 4 15 7 3
4 9 6 21 12 6
5 4 1 5 1 0
#include <iostream>
using namespace std;
struct process
{
int process_no;
int arrival_time;
int burst_time;
int completion_time;
int turnAround_time;
int waiting_time;
};
int currentTime = 0;
bool allDone = false;
while (!allDone)
{
allDone = true;
for (int i = 0; i < n; i++)
{
if (remainingTime[i] > 0)
{
allDone = false;
if (remainingTime[i] > qt)
{
currentTime = currentTime + qt;
remainingTime[i] = remainingTime[i] - qt;
}
else
{
currentTime = currentTime + remainingTime[i];
arr[i].completion_time = currentTime;
remainingTime[i] = 0;
}
}
}
}
}
process arr[n];
cout << "ENter the process details :" << endl;
for (int i = 0; i < n; i++)
{
cout << "Process " << i + 1 << ":\n";
arr[i].process_no = i + 1;
cout << "Arrival Time :";
cin >> arr[i].arrival_time;
cout << "Burst Time :";
cin >> arr[i].burst_time;
}
findCurrentCompletionRemainingTime(arr, n, qt);
findTurnAroundTime(arr, n);
findWaitingTime(arr, n);
printRoundRobinScheduling(arr, n);
cout << "Solved by : Mr. Sahil Kumar / PtuCoder !" << endl;
return 0;
}
OUTPUT ➖
Enter the size of process :4
Enter the time quantum :2
Process 1:
Arrival Time :4
Burst Time :6
Process 2:
Arrival Time :2
Burst Time :5
Process 3:
Arrival Time :8
Burst Time :5
Process 4:
Arrival Time :7
Burst Time :9
User Interface: ➖ Operating systems provide user interfaces through which users
interact with the computer. This interface can be command-line based (text-based) or
graphical, where users interact with icons, windows, and menus.
File System: ➖ The OS provides a file system that organizes and stores data on storage
devices such as hard drives and SSDs. It manages files, directories, and file access
permissions.
● Unix: ➖ Unix is a family of multitasking, multi user computer operating systems that
derive from the original AT&T Unix, developed in the 1970s.
These are just some of the key aspects and examples of operating systems. They play a
crucial role in enabling users to interact with computers and utilise their capabilities
effectively.
INDEX
Sr. Date: Title : Page Teacher’s
No. No. Sign/Remarks.