Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 53

Lab Manual

Operating Systems
(C201_3330701)
Semester – 3

Government Polytechnic, Ahmedabad


Programme :Diploma in Computer Engineering

Name of Student: Tank Dhruvik Rajeshbhai

Enrollment Number: 206170307025

Semester :3 Division : A

GTU Term Date : / / To / /


GOVERNMENT POLYTECHNIC, AHMEDABAD

COMPUTER ENGINEERING DEPARTMENT

CERTIFICATE

This is to certify that Mr. / Miss

of Diploma in Computer Engineering, Semester , Enrolment No.

has satisfactorily completed his/her term work in

for the term ending in .

Date of Submission: - / /

Sign Sign

(Course in Charge) Head of the Department


Practical Index
PRAC. PRACTICAL CO FACULTY
RB1 RB2 RB3 RB4 TOTAL DATE
NO. NAME NO. SIGN
Install an Operating
System & compare any
1 C201.1
two types of OS based
on their features.
Compare various
2 process scheduling C201.2
algorithms.
Test and run general
purpose, directory
3 C201.5
related and file related
Linux commands.
Test and run process
related ,filters and other
4 C201.5
command like
expr,tee,set etc.
Test commands related
5 with File editing with C201.5
Vi, Vim, gedit, gcc.
i.) Create a shell script
to print bio-data.
6 ii) Create a Shell script C201.5
to read from command
line using for loop.
i) Create a shell script to
read and display content
of a file.
ii) Create a Shell
7 C201.5
script to find numbers
of characters, words &
lines of a given input
file.
i)Create a Shell script to
append content of one
file to another.ii) Create
8 C201.5
a shell script to copy
content of two files in a
third file
i) Create a Shell script
to accept a string in
lower case letters from
a user, & convert to
9 upper case letters. C201.5
ii) Create a script to
concatenate two strings
and find the length of
the resultant string.
Create a Script to
10 reverse a string and C201.5
display it.

Create a Script to check


11 a string is palindrome. C201.5

Create a script to find


average of the numbers
12 C201.5
entered at command
line.
Create a script to find
13 sum of digits in given 5- C201.5
digit number.
Create a Shell script for
14 a calculator using case.
C201.5

Create a shell script to


15 reverse the digits of a C201.5
given 5-digit number.

Signature of Faculty Grade


OS 1
(3330701)
PRACTICAL – 1
AIM: Install an Operating System & compare any two types of OS based on their
features.

Part 1: Install an Operating system. Take screen shots of step and explain each
step in brief.

Steps To Install Windows 10 on VMware:

1:After Opening Vmware Click On “ Create A New Virtual Machine “.

2. After This Wizrd Appears , Select Typical Installation and Click On Next
OS 2
(3330701)

3. Select Your ISO File from Your Drive and Click on Next

4. Select The Name Of OS You are installing and click on next.


OS 3
(3330701)

5. Give Your Virtual Machine A name and Click on next.

6. Select The Size of Your Virtual machine and Click On Next.


OS 4
(3330701)

7. Click On Finish To Confirm creating Your Virtual Machine.

8. When This Wizard Appears , select Your favorable language and click on next.
OS 5
(3330701)

9. Click On install now

10. Select Your Os and Click On Next.


OS 6
(3330701)

11. Select The Drive For Partition.

12. Your OS is Currently Being Installed.


OS 7
(3330701)

13. After Installation , Select the appropriate Information and Procced To


finish installation.
OS 8
(3330701)

14. Your Virtual Machine Has Been Successfully Installed.


OS 9
(3330701)

Part 2: Pick any two different OS and compare them based on their features.

 Comparison Between macOS & Windows.

WINDOWS MACOS

It was developed and is owned by It was developed and is owned by


Microsoft Incorporation. Apple Incorporation.

It was launched in 1985. It was launched in 2001.

It is designed for PC of all It is specifically designed for Apple


companies. mac computers.

Current stable version is Windows 10. Current stable version is mac


10.15.1 (Catalina).

It is for workstation, personal Its target system type is


computers, media center, tablets and workstation, personal computers
embedded systems. and embedded systems.

Computer architectures supported by Computer architectures supported are


Windows are IA-32, x86-64, IA- 64, x86-64(10.4.7-present), IA-
ARM, Alpha, MIPS and PowerPC. 32(10.4.4-10.6.8) and
PowerPC(10.0-10.5.8).

File systems supported are NTFS, File systems supported are HFS+,
FAT, ISO 9660, UDF, HFS+, FATX APFS, HFS, UFS, AFP, ISO 9660,
OS 10
(3330701)

and HFS. FAT, UDF, NFS, SMBFS, NTFS,


FTP, WebDAV and ZFS.

Kernel type is Hybrid with modules Kernel type is Hybrid with modules
here. here also.

Package management is MSI or Package management is macOS


custom installer. installer.

Update management is Windows Update management is Software


Update. Update.

The native APIs are Win32 and NT The native APIs are Carbon,
API. Cocoa, Java and BSD-POSIX.

Part 3: List various Operating systems as many as you can.

 List of Operating Systems

Names Of OS Ownership
Arthur
ARX
MOS
Acorn Computers
RISC iX
RISC OS

Fire OS Amazon

Amiga OS Amiga Inc.


OS 11
(3330701)

AmigaOS 1.0-3.9 (Motorola 68000)

AmigaOS 4 (PowerPC)

Amiga Unix (a.k.a. Amix)

AMSDOS

Contiki

CP/M 2.2 Amstrad

CP/M Plus

SymbOS

Atari DOS (for 8-bit computers)


Atari
Atari TOS

BeOS

BeIA
BeOS r5.1d0BeOS r5.1d0
magnussoft ZETA (based Be Inc.
on BeOS r5.1d0 source code,
developed by yellowTAB)

Windows XP
Windows 7
Windows 8 Microsot Corporation
Windows 10
OS 12
(3330701)

Chromium OS
Chrome OS Google
Android
Apple DOS

macOS

Apple Pascal Apple Inc.

iOS

Unix
Bell Labs
MINI-UNIX

Burroughs MCP

HDOS - ran on the H8 and Burroughs Corporation, Unisys


Heath/Zenith Z-89 series

HT-11 - a modified version


of RT-11 that ran on
the Heathkit H11
HP Multi-Programming
Executive (MPE, MPE/XL, and
MPE/iX) – runs on HP 3000 Hewlett-Packard, Hewlett
and HP e3000 mini-computers Packard Enterprise
HP-UX – runs on HP9000 and
Itanium servers (from small
to mainframe-class
computers)
CP-6
Honeywell

Harmony OS Huawei
OS 13
(3330701)

LiteOS
iRMX
Intel Corporation
ISIS, ISIS-II

INTEGRITY Green Hills Software


OS 14
(3330701)

PRACTICAL – 2
AIM: Compare various process scheduling algorithms.

Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst time(finish T- (TAT-CPU req)
Arrival time)
P1 0 5
P2 1 2
P3 2 4
P4 5 2

Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst time(finish T- (TAT-CPU req)
Arrival time)
P1 0 8
P2 1 3
P3 2 4
P4 3 2

Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst time(finish T- (TAT-CPU req)
Arrival time)
P1 0 6
P2 2 5
P3 4 8
P4 5 3
P5 6 3

Calculate average turnaround time and avg waiting time using


FCFS,SJF,SRTN,RR and compare them.
OS 15
(3330701)

Table 1 using FCFS


Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst time(finish T- (TAT-CPU
Arrival time) req)

P1 0 5 4 6 0

P2 1 2 3 5 3

P3 2 4 8 4 2

P4 5 2 10 11 9

Total: 13 Average: 6.8s 3.2ms

GANTT CHART:

P1 P2 P3 P4
0 5 7 11 13

Table 1 using SJF


Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst (TAT-CPU
time(finish T- req)
Arrival time)

P1 0 5 5 5 0

P2 1 2 4 3 5

P3 2 4 8 6 8

P4 5 2 11 10 7
OS 16
(3330701)

Total: 13 Average: 6ms 5ms

GANTT CHART:

P1 P2 P4 P3
0 5 7 9 13

Table 1 using SRTN


Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst time(finish T- (TAT-CPU
Arrival time) req)

P1 0 5 7 10 1

P2 1 2 3 12 7

P3 2 4 13 8 6

P4 5 2 9 3 9

Total: 13 Average: 8.3ms 4.5ms

GANTT CHART:

P1 P2 P1 P4 P3
0 1 3 7 9 13

Table 1 using RR
Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst time(finish T- (TAT-CPU
Arrival time) req)

P1 0 5 10 10 5
OS 17
(3330701)

P2 1 2 5 4 2

P3 2 4 13 11 7

P4 5 2 12 7 5

Total: 13 Average: 8ms 4.5ms

RR = 3ms

Gantt chart:
P1 P2 P3 P1 P4 P3
0 3 5 8 10 12 13

Table 2 using FCFS


Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst time(finish T- (TAT-CPU
Arrival time) req)

P1 0 8 8 8 8

P2 1 3 11 5 10

P3 2 4 15 4 6

P4 3 2 17 11 7

Total: 17 Average: 7ms 7.8s

GANTT CHART:

P1 P2 P3 P4
0 8 11 15 17
OS 18
(3330701)

Table 2 using SJF


Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst time(finish T- (TAT-CPU
Arrival time) req)

P1 0 8 8 8 0

P2 1 3 13 12 9

P3 2 4 17 15 11

P4 3 2 10 7 5

Total: 17 Average: 10.5ms 6.25ms

GANTT CHART:

P1 P4 P2 P3
0 8 10 13 17

Table 2 using SRTN


Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst time(finish T- (TAT-CPU
Arrival time) req)

P1 0 8 17 17 9

P2 1 3 4 3 0

P3 2 4 10 8 4
OS 19
(3330701)

P4 3 2 6 3 1

Total: 17 Average: 7.75ms 3.5ms

GANTT CHART:

P1 P2 P4 P3 P1
0 1 4 6 10

Table 2 using RR
Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst time(finish T- (TAT-CPU
Arrival time) req)

P1 0 8 17 11 7

P2 1 3 6 3 7

P3 2 4 15 17 2

P4 3 2 11 6 3

Total: 17 Average: 6.7s 4.8s

RR = 3ms

Gantt chart:
P1 P2 P3 P4 P1 P3 P1
0 3 6 9 11 14 15 17
OS 20
(3330701)

Table 3 using FCFS


Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst time(finish T- (TAT-CPU
Arrival time) req)

P1 0 6 6 5 7

P2 2 5 11 8 6

P3 4 8 19 9 9

P4 5 3 21 13 12

P5 6 3 24 7 13

Total: 24 Average: 8.5ms 9.8ms

GANTT CHART:

P1 P2 P3 P4 P5
0 6 11 19 21 24
OS 21
(3330701)

Table 3 using SJF


Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst time(finish T- (TAT-CPU
Arrival time) req)

P1 0 6 6 8 4

P2 2 5 17 5 5

P3 4 8 24 13 3

P4 5 3 9 2 9

P5 6 3 12 4 8

Total: 24 Average: 6.4ms 5.8ms

GANTT CHART:

P1 P4 P5 P2 P3
0 6 9 12 17 24
OS 22
(3330701)

Table 3 using SRTN


Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst time(finish T- (TAT-CPU
Arrival time) req)

P1 0 6 6 3 5

P2 2 5 17 11 9

P3 4 8 24 17 12

P4 5 3 9 3 2

P5 6 3 12 9 7

Total: 24 Average: 8.6ms 7s

GANTT CHART:

P1 P4 P5 P2 P3
0 6 9 12 17 25
OS 23
(3330701)

Table 3 using RR
Process name Arrival time Required CPU Finish time Turnaround Waiting time
burst time(finish T- (TAT-CPU
Arrival time) req)

P1 0 6 18 15 11

P2 2 5 20 11 15

P3 4 8 24 19 19

P4 5 3 12 6 9

P5 6 3 15 7 6

Total: 24 Average: 11.6ms 12ms

RR = 3ms

Gantt chart:
P1 P2 P3 P4 P5 P1 P2 P3 P3
0 3 6 9 12 15 18 20 23 24
OS 24
(3330701)

PRACTICAL – 3
AIM: Test and run general purpose, directory related and file related
Linux commands.

Example:
cd- Change Directory
Syntax-
Usage-
Options-
 Run command with various options and paste output here
Directory Related Commands
1) pwd: Print Working Directory
Syntax: pwd
Usage: Print working directory name.
Output:

2) cd: Change Directory


Syntax:cd [directory]
Usage: Change working directory
Examples:
Cd : changes working directory to home directory
Output:
OS 25
(3330701)

3) mkdir: Make Director Syntax:


mkdir directory Usage: Creates
new directory. Examples: mkdir
Test
Creates a new directory named Test.
Output: Directory named “new” has been created.

4) rmdir: Remove Directory


Syntax: rmdir directory
Usage: Removes an empty directory. If the directory is not empty, it will not be removed.
Examples: rmdir Test
Removes directory named Test if it is empty.
Output: Directory Name “new” has been removed

File Related Commands


1) cat:
Syntax:
cat file : Displays file contents cat
> file: Creates new file.
cat >> file: Appends data to an existing file.
Usage: Displays file contents, Creates new file, Appends data to an existing file.
Output:
OS 26
(3330701)

2) Is: List files Syntax:


Is [directory]
Usage: List out contents of a directory
Options:
A: List out all files including hidden ones
D: List only directories
F: Mark directories with /, executable files with *, symbolic links with @ and
sockets with =
l: Long listing showing protections, number of links, owner, size, and time of last modification
S: Size in kilobytes
Output:

3) cp: Copy command


Syntax: cp [-irp] file1 [file2 ] target
Usage: copies a file or group of files.
Options:
i: Interactive copying (Asks before overwriting a destination file.)
r:Recursive copying (It copies directory structure.)
Output:
OS 27
(3330701)

4) mv: Move / Rename file Syntax:mv [


-if ] file 1 [file2 ...] target
Usage: Renames a file, or moves a file or group of files.
Examples:
mv file1 renames file 1 to file 2
file 2
mv old Moves “old” file to directory “archive”
archive
Output: file Named temp.txt is moved to desktop

5) rm: Remove file Syntax:


rm [-f] [-i ] [-r] file
Usage: Removes files (Deletes files)
Options:
i: Interactive removal (Asks before each removal.)
r: Recursive removal (Performs recursive deletion in directory.) f:
Forceful removal (Removes write protected file also.) Output:
OS 28
(3330701)

PRACTICAL – 4
AIM: Test and run process related ,filters and other command like
expr, tee, set etc

Test and Run cal, date, echo, passwd, who, tty,man,ps,time,kill,expr,tee,set.


Use man command to check options available with commands.

1) Cal :- Gives view of calender in terminal.

Output:

Using man command:


OS 29
(3330701)

2) Date : - Print system date day time in terminal


Output:

Using man command:

3) Echo : - Print message in terminal


Output:
OS 30
(3330701)

Using man command:

4) tty : - Display Information Related to Terminal

Output:

Using man command:


OS 31
(3330701)

5) man : - Display Information Related to entered commands

Output:
OS 32
(3330701)

6) Ps : - ps is a command used for for viewing information related with the processes on a
system

Output:

Using man command:

7) kill : - kill Command in Linux is used to terminate a process manually

Output:
OS 33
(3330701)

Using man command:

8) tee : - tee command reads the standard input and writes it to both the standard output
and one or more files.

Output:

Using man command:


OS 34
(3330701)

9) set : - set command is used to set and unset certain settings within the shell
environment.

Output:
OS 35
(3330701)
PRACTICAL – 5
AIM: Test commands related with File editing with Vi, Vim, gedit, gcc.

VI Editor
Commands:

i. vi biodata
ii. ls
iii. cat biodata.

Output:

VIM Editor
Commands:

i. vim biodata
ii. ls
iii. cat biodata

Output:
OS 36
(3330701)

Gedit Editor
Commands:

i. gedit new3.txt
ii. cat new3.txt

Output:

GCC Editor
Commands:

i. touch ba.txt
ii. vi ba.txt
iii. gcc ba.txt

Output:
OS 37
(3330701)

PRACTICAL – 6
AIM: i.)Create a shell script to print bio-data.
ii) Create a Shell script to read from command line using for loop.

i.)Create a shell script to print bio-data.

echo "***** THIS IS MY BIO DATA *****"


echo " "
echo " ***Basic Details*** ***Career Details***"
echo " "
echo "Name - Dhruvik Tank Education - *Diploma From Government Polytechnic
Ahmedabad "
echo "Age - 19 - SSC Passed"
echo "Height - 5.9ft"
echo "Weight - 75 Kgs"
echo "Blood Group - B+"
echo "Languages Known - Hindi,English,Gujarati"
echo " "
echo " ***Family Details*** ***Address & Contact***"
echo " "
echo "Father's Name - Rajeshbhai Tank Address - B-13 Sapna Appartment "
echo "Mother's Name - Manjulaben Tank Near Chamak Chuna"
echo "Brother's Name - Akshay Tank Thakkarnagar,Ahmedabad 382350."
echo "Occupation - Business Contact - 8000006273"
Output:
OS 38
(3330701)

ii) Create a Shell script to read from command line using for loop.

n=$#
for i in $*
do
echo $i
done

Output:
OS 39
(3330701)

PRACTICAL – 7
AIM: i) Create a shell script to read and display content of a file.
ii) Create a Shell script to find numbers of characters, words &
lines of a given input file.

i) Create a shell script to read and display content of a file.

echo "Enter the name of file of whose content You want to read: " read
filename

echo "The content of file is : "


cat $filename

Output:

ii) Create a Shell script to find numbers of characters, words & lines of a
given input file.

echo "enter file name:"


read filename
c=`cat $filename | wc -c`
w=`cat $filename | wc -w`
l=`cat $filename | wc -l`

echo "No Of characters in file is $c"


echo "No Of Words in File is $w"
echo "No of Lines in File is $l"

Output:
OS 40
(3330701)

PRACTICAL – 8
AIM: i)Create a Shell script to append content of one file to another.
ii) Create a shell script to copy content of two files in a third file

i) Create a Shell script to append content of one file to another.

echo "Enter First Filename:"


read first
echo "Enter Second Filename:"
read second

cat $first > temp.txt


cat $second >> temp.txt

echo "Content of file is:"


cat temp.txt

Output:
OS 41
(3330701)

ii) Create a shell script to copy content of two files in a third file.
echo "Enter First Filename:"
read firstfile
echo "Enter Second Filename:"
read secondfile

cat $firstfile > thirdfile.txt


cat $secondfile >> thirdfile.txt

echo "Content of third file is:"


cat thirdfile.txt

Output:
OS 42
(3330701)

PRACTICAL – 9
AIM: i) Create a Shell script to accept a string in lower case letters from
a user, & convert to upper case letters.
ii) Create a script to concatenate two strings and find the length of
the resultant string.

i) Create a Shell script to accept a string in lower case letters from a user,
& convert to upper case letters.
echo "Enter Text In Lowercase:"
read lwr

echo "Text in Uppercase is :"


echo "${lwr^^}"

Output:
OS 43
(3330701)

ii) Create a script to concatenate two strings and find the length of the
resultant string.
echo "Enter First String:"
read firststring
echo "Enter Second String:"
read secondstring

third=$firststring$secondstring

len=`echo $third | wc -c`


len=`expr $len - 1`
echo "Length Of Resultant String:$len"

Output:
OS 44
(3330701)
PRACTICAL – 10
AIM: Create a Script to reverse a string and display it.

echo "Enter the string you want to reverse:" read string


len=`echo -n $string | wc -c` echo
"length is: $len"
while test $len -gt 0 do
rev=$rev`echo $string | cut -c $len`
echo rev=$rev
len=`expr $len - 1`
done
echo "Reversed string is: $rev"

Output:
OS 45
(3330701)

PRACTICAL – 11
AIM: Create a Script to check a string is palindrome.

echo "Enter a string:"


read str
len=` echo $str | wc -c `
len=` expr $len - 1 `
i=1
j=` expr $len / 2` while
test $i -le $j
do k=` echo $str | cut -c $i` l=`
echo $str | cut -c $len` if
test $k != $l
then
echo "String is Not Palindrome"
exit
fi
i=`expr $i + 1`
len=`expr $len - 1`
done
echo "String is Palindrome"

Output:
OS 46
(3330701)
PRACTICAL – 12
AIM: Create a script to find average of the numbers entered at
command line.

sum=0
count=$#

if [ $count -lt 1 ]; then


echo "ERROR: No numbers given. Please give some numbers as command line arguments."
exit 1
fi

while [ -n "$1" ]; do
sum=$(expr $sum + $1)
shift
done

avg=$(echo "scale=4; $sum / $count"|bc)

echo "The average of given $count numbers is $avg"

Output:
OS47
(3330701)

PRACTICAL – 13
AIM: Create a script to find sum of digits in given 5-digit number.

Num=45678
g=$Num
s=0

while [ $Num -gt 0 ]


do
# get Remainder k=$
(( $Num % 10 ))

# get next digit Num=$


(( $Num / 10 ))

# calculate sum of #
digit
s=$(( $s + $k ))
done
echo "sum of digits of $g is : $s"

Output:
OS 48
(3330701)
PRACTICAL – 14
AIM: Create a Shell script for a calculator using case.

echo "14.Create a Shell script for a calculator using case." echo

"Enter a number"

read a

echo "Enter a number"

read b

echo "Enter Operator [+,-,*,/]"

read op

case $op in

+) expr $a + $b ;;

-) expr $a - $b ;;

\*) expr $a \* $b ;;

/) expr $a / $b ;;

esac

Output:
OS 49
(3330701)
PRACTICAL – 15
Create a shell script to reverse the digits of a given 5-digit number.

echo "Enter a 5 Digit Number:"


read num
ans=0

while [ $num -ne 0 ]


do
dig=`expr $num % 10`
ans=`expr $ans \* 10 + $dig`
num=`expr $num / 10`
done
echo "Reversed Number is : $ans"

Output:

You might also like