OS LAB (PCS-506) : Submitted in Partial Fulfilment of The Requirement For The V Semester
OS LAB (PCS-506) : Submitted in Partial Fulfilment of The Requirement For The V Semester
OS LAB (PCS-506) : Submitted in Partial Fulfilment of The Requirement For The V Semester
Term-Work
On
OS LAB (PCS-506)
By
Shyam Yadav
20011180
Faculty-in-Charge
Assistant Professor
I, …………….., hereby declare the work, which is being presented in the term-work, entitled “OS LAB “
in partial fulfillment of the requirement for the award of the degree B,Tech in the session 2022-2022,
is an authentic record of my own work carried out under the supervision of Mr.Shashi Kumar Sharma.
The matter embodied in this term work has not been submitted by me for the award of any other
degree.
no………… Roll no……….to Graphic Era Hill University Bhimtal Campus for the award of Bonafede
work carried out by his/ her. He/She has worked under my guidance and supervision and fulfilled
(…………………) (……………………)
2. date +%m
Output- Displays the month of year (01 to 12).
3. date +%h
Output- Displays abbreviated month name (Jan to Dec).
4. date +%y
Output- Displays last two digits of the year(00 to 99).
5. date +%s
Output- Display the seconds since 1970-01-01 00:00:00 UTC.
6. date +%M
Output- Display the minutes.
7. date +%Y
Output- Display four-digit year.
8. date +%H
Output- Display the hour.
9. date +%S
Output- Display the seconds (00….60).
10.cal
Output- cal command is a calendar command in Linux which is used to
see the calendar of a specific month or a whole year.
13.ls
Output- The ls command is used to list files or directories in Linux and
other Unix-based operating systems.
14.ls -s
Output- To list files or directories with their sizes.
15.ls [p]*
Output- To list all the files or directories starting from p.
16.ls [a-h]*
Output- To list all the files or directories starting from letters a to h.
17.man
Output- Used to display the user manual of any command that we can
run on the terminal.
18.man ls
Output- Manual page of ls.
19.lp filename
Output-
22.Uname
Output- The command ‘uname‘ displays the information about the
system.
23.cat >newfile
Output- Will create a file named newfile.
24.cat filename
Output- To view the file named filename.
25.cat >>filename
Output- To edit the file named filename.
28.head -2 filename
Output- Prints the first 2 lines of the specified file.
29.tail filename
Output- Prints the last 10 lines of the specified file.
32.rm filename
Output- To remove or delete a file.
33.touch filename
Output- To create a blank file.
2. #include<iostream>
#include<unistd.h>
using namespace std;
int main()
{
if( fork() )
{
if( !fork() )
{
fork();
cout<<”A”<<endl;
}
else
{
cout<<”B”<<endl;
}
}
else
{
cout<<”C”<<endl;
}
return 0;
}
Practical – 3
#include <iostream>
using namespace std;
#define max 10
int main()
{
int i,n,a[max],b[max],c[max],tat[max],wt[max];
float awt=0.0, atat=0.0;
cout<<"Enter the number of processes ";
cin>>n;
cout<<"Enter the arrival time ";
for(i=1; i<=n; i++)
{
cin>>a[i];
}
cout<<"Enter the burst time ";
for(i=1; i<=n; i++)
{
cin>>b[i];
}
cout<<"Process Arrival time Burst time Completion time Turnaround time
Waiting time\n";
for(i=1; i<=n; i++)
{
c[1]=b[1];
c[i+1]=c[i] + b[i+1];
tat[i]=c[i] - a[i];
wt[i]=tat[i] - b[i];
atat=atat+tat[i];
awt=awt+wt[i];
cout<<(i+1)<<"\t\t"<<a[i]<<"\t\t"<<b[i]<<"\t\t"<<c[i]<<"\t\t"<<tat[i]<<"\t\t"<<
wt[i]<<"\n";
}
cout<<"Average turnaround time= "<<(atat/n)<<"\n";
cout<<"Average waiting time= "<<(awt/n)<<"\n";
return 0;
}