OS LAB (PCS-506) : Submitted in Partial Fulfilment of The Requirement For The V Semester

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

A

Term-Work

On

OS LAB (PCS-506)

Submitted in partial fulfilment of the requirement for the V semester


B.Tech

By

Shyam Yadav

20011180

Faculty-in-Charge

Shashi Kumar Sharma

Assistant Professor

DEPARTMENT OF COMPUTER SCIENCE &ENGINEERING

GRAPHIC ERA HILL UNIVERSITY, BHIMTAL CAMPUS


2022-22
STUDENT’S DECLARATION

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.

Date: ………… ……………….

(Full signature of student)


CERTIFICATE

The term-work entitled “……………….” being submitted by……………………………. S/o………….enrolment

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

the requirement for the submission of reports.

(…………………) (……………………)

Faculty-in-Charge (HOD, CSE Dept.)


Practical – 1

Objective- To study basic UNIX functions.


1. date
Output- With no options, the date command displays the current date
and time, including the abbreviated day name, abbreviated month
name, day of the month, the time separated by colons, the time zone
name, and the year.

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.

11.cal month year


Output- Shows calendar of selected month and year.
12.echo ”text”
Output- echo command in linux is used to display line of text/string that
are passed as an argument .

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-

20.who & whoami


Output- It displays login name of the users, terminal line numbers,
login time of the users in to system, remote host name of the user.
It displays the username of the current user when this command is
invoked.
21.Uptime
Output- Uptime is a command that returns information about how long
your system has been running together with the current time, number
of users with running sessions, and the system load averages for the past
1, 5, and 15 minutes.

22.Uname
Output- The command ‘uname‘ displays the information about the
system.

File manipulation commands-

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.

26.grep search_word filename


Output- If searched word is found in that file then it will be highlighted in
red color.
27.head filename
Output- Prints the first 10 lines of the specified file.

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.

30.cp src_file dest_file


Output- All the data is copied from src_file to dest_file.
31.mv oldfile newfile
Output- It renames a file or folder .

32.rm filename
Output- To remove or delete a file.

33.touch filename
Output- To create a blank file.

34.cat file1 file2 >>file3


Output- Will merge the contents of files in respective order and will
insert that content in "file3".
Practical – 2

Objective- Implement fork() System call.


1. #include<iostream>
#include<unistd.h>
using namespace std;
int main()
{
fork();
cout<<”Hello my name is Yash”<<endl;
return 0;
}

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

Objective- To implement First Come First Out (FCFS).

#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;
}

You might also like