Professional Documents
Culture Documents
Laboratory Manual
OPERATING SYSTEM LABORATORY
Code: CS 693
Name: ____________________________
University Roll No: _____________________
College Roll No: _______________________
Year:___________ Semester: _________
Section: _________ Group:____________
Session: _____________________________
1
Department of Computer Science and Engineering
General Information
Course 2 Session
Credit
Technical Laboratory
Assistant/s
2
Department of Computer Science and Engineering
PO PO Description
Number
PO2 Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principle of
mathematics, natural science and engineering sciences.
PO3 Design / development of solutions: Design solutions for complex engineering problems
and design system components or processes that meet the specified needs with
appropriate consideration for the public health and safety, and the cultural, societal, and
environmental considerations.
PO4 Design / development of solutions: Design solutions for complex engineering problems
and design system components or processes that meet the specified needs with
appropriate consideration for the public health and safety, and the cultural, societal, and
environmental considerations.
PO5 Modern tool usage: Create, select, apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering
activities with an understanding of the limitations
PO6 The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
PO7 The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
PO8 Ethics: Apply ethical principles and commit to professional ethics and responsibilities
and norms of the engineering practice.
PO9 Individual and team work: Function effectively as an individual, and as a member or
leader in diverse teams, and in multidisciplinary settings.
and write effective reports and design documentation, make effective presentations,
and give and receive clear instructions
PO CO
CO 1 CO 2 CO 3
PO 1
PO 2
PO 3
PO 4
PO 5
PO 6
PO 7
PO 8
PO 9
PO
10
PO
11
PO
12
Course policies
1. Attendance
Attendance is compulsory. Please be respectful to your classmates by being on time. Cell
phones should be turned off and kept out of sight.
2. Calculator policy
3. Plagiarism
4. Disability Support
If you have a disabling condition which may interfere with your ability to successfully complete
this module, please contact Faculty in charge.
5. Make-up Experiment
Make-up for a missing experiment will not be offered, normally. The only exceptions to that are
illness or emergency (e.g., death in family, a traffic accident, etc.), in which case you may
contact your faculty in charge.
As per policy you have to perform at least one beyond syllabus experiment from the list of
beyond syllabus experiments provided in Part II.
As per policy you have to perform at least one virtual laboratory experiment. You may select
your virtual experiments from:.
8. Micro Project
Continuous assessment
Lab reports [15%]
Experiment number, Objective, theory, procedure, results, discussion and conclusion.
Viva [20%]
There is a 10-minute viva-voce during examination time.
Grading Scale
Grade Percent score
0 90
E 80 and <90
A 70 and <80
B 60 and <70
C 50 and <60
D 40 and <50
F <40
01 c) UNIX Filters
Assignment 01
Theory:
Basic Commands
Linux
Description
Command
date The date command tells the system to print the date and time
cal Displays calendar
who show who is logged on
echo Display text on the screen. Mostly useful when writing shell scripts
bc Basic calculator
Informational Commands
Linux Command Explanation
ps Lists currently running process (programs)
w Show who is logged on and what they are doing
id Print user-id and group id's
Displays CPU processes in a full-screen GUI. A great way to see
top
the activity on your computer in real-time. Type Q to quit.
free Displays amount of free and used memory in the system.
Prints system information to the screen (kernel version, machine
uname a
type, etc.)
wc Print the number of newlines, words, and bytes in files
System Administration
uptime Used to find the duration for which the system has been running
Other Utilities
Linux
Description
Command
clear Clear the screen
more Display a file, or program output one page at a time.
An improved replacement for the more command. Allows you to scroll
less
backwards as well as forwards.
grep Search for a pattern in a file or program output.
lpr Print a file or program output.
sort Sort a file or program output.
Problem statement:
Program:
Discussions:
Questionnaires:
Grade awarded:
Assignment 02
Title: Introduction to Shell Programming
Objective: To get familiar with shell program
Theory:
Writing a Shell Script:
Step 1: To create a shell script, open a new empty file in your editor. Any text editor will do: vi,
emacs, gedit, dtpad etc. are all valid.
Step 2: Put UNIX commands or your statements in the new empty file, like you would enter them
on directly in the command line.
Step 3: Give your script a sensible name that gives a hint about what the script does. Make sure
that your script name does not conflict with existing commands. In order to ensure that no
confusion can rise, script names often end in .sh; even so, there might be other scripts on your
system with the same name as the one you chose. Check using which, whereis and other
commands for finding information about programs and files.
Commands and Syntaxes for Shell Programming:
(1) echo [options] [string, variables...]
Displays text or variables value on screen.
(2) if...else...fi
If given condition is true then command1 is executed otherwise command2 is executed.
Syntax:
if condition
then
command1 if condition is true or if exit status
of condition is 0(zero)
...
...
else
command2 if condition is false or if exit status
of condition is >0 (nonzero)
...
...
fi
(3) Multilevel if-then-else
Syntax:
if condition
then
condition is zero (true 0)
execute all commands up to elif statement
elif condition1
condition1 is zero (true 0)
..
command;;
pattern2) command
...
..
command;;
*) command
...
..
command;;
esac
(7) The read Statement Use to get input from keyboard and store them to variable.
Syntax:
read varible1, varible2,...varibleN
Command Line Arguments:
(1) The $# Variable
Whenever you execute a shell program, the special shell variable $# gets set to the number of
arguments that were typed on the command line.
(2) The $* Variable
The special variable $* references all the arguments passed to the program. This is often useful in
programs that take an indeterminate or variable number of arguments.
(3) The $0 Variable
Whenever you execute a shell program, the shell automatically stores the name of the program inside
the special variable $0. This can be used to advantage when you have two or more programs that are
linked under different names and you want to know which one was executed. Its also useful for
displaying error messages because it removes the dependency of the filename from the program. If the
name of the program is referenced by $0, subsequently renaming the program will not require the
program to be edited
Arrays:
Array indexing starts at zero. An array element is accessed with a subscript, which is an integer-valued
expression enclosed inside a pair of brackets. You dont declare the maximum size of a shell array; you
simply assign values to elements as you need them. The values that you can assign are the same as
for ordinary variables.
$ arr[0]=hello
$ arr[1]=some text
To retrieve an element from an array:
$ echo ${array[0]}
Page: ___ / ___
Department of Computer Science and Engineering
hello
$ echo ${array[1]}
some text
Basic Operators in Shell Scripts:
Relational Operators
Operator Description Example
Checks if the values of two operands are equal
-eq [ a eqb ] is not true.
or not, if yes then condition becomes true.
Checks if the values of two operands are equal
-ne or not, if values are not equal then condition [ a neb ] is true.
becomes true.
Boolean Operators
Operator Description Example
This is logical negation. This inverts a true
! [ ! false ] is true.
condition into false and vice versa.
or
sh script_name.sh
Problem Statement:
Program:
Discussions:
Questionnaires:
Page: ___ / ___
Department of Computer Science and Engineering
Grade awarded:
Assignment 03
Title: Memory Management
Objective: To manage memory using Linked List method and implement Allocation Algorithms.
Theory: One of the simplest methods for memory allocation is to divide memory into several fixed-
sized partitions. Each partition may contain exactly one process. In this multiple-partition method, when
a partition is free, a process is selected from the input queue and is loaded into the free partition. When
the process terminates, the partition becomes available for another process. The operating system
keeps a table indicating which parts of memory are available and which are occupied. Finally, when a
process arrives and needs memory, a memory section large enough for this process is provided. When
it is time to load or swap a process into main memory, and if there is more than one free block of
memory of sufficient size, then the operating system must decide which free block to allocate. Best-fit
strategy chooses the block that is closest in size to the request. First-fit chooses the first available block
that is large enough. Worst-fit chooses the largest available block.
Problem statement:
Program:
Discussions:
Questionnaires:
Grade awarded:
Assignment 04
Title: Process Management
Objective: To create child process.
Theory:
Parent and Child Process:
Each UNIX process has two ID numbers assigned to it: Process ID (pid) and Parent process
ID (ppid). In the Unix operating system, every process except process 0 (the swapper) is
created when another process executes the fork() system call. The process that invoked fork is
the parent process and the newly created process is the child process. Every process (except
process 0) has one parent process, but can have many child processes.
Process 0 is a special process that is created when the system boots; after forking a child
process (process 1), process 0 becomes the swapper process (sometimes also known as the
"idle task"). Process 1, known as init, is the ancestor of every other process in the system.
Problem statement:
Program:
Discussions:
Questionnaires:
Grade awarded:
Assignment 05
Title: Understanding Orphan and Zombie Process
Objective: To create orphan and zombie Process
Theory:
Zombie Process:
The operating system maintains a table that associates every process, by means of its process
identifier (generally referred to as "pid") to the data necessary for its functioning. When a process
terminates its execution, the operating system releases most of the resources and information related
to that process, but still keeps the data about resource utilization and the termination status code,
because a parent process might be interested in knowing if that child executed successfully and the
amount of system resources it consumed during its execution.
By default, the system assumes that the parent process is indeed interested in such information at the
time of the child's termination, and thus sends the parent the signal SIGCHLD to alert that there is
some data about a child to be collected. Such collection is done by calling a function of the wait family.
As soon as this collection is made, the system releases those last bits of information about the child
process and removes its pid from the process table. However, if the parent process lingers in collecting
the child's data (or fails to do it at all), the system has no option but keep the child's pid and termination
data in the process table indefinitely. Such a terminated process whose data has not been collected is
called a zombie process, or simply a zombie, in the UNIX parlance.
Orphan Process:
Orphan processes are an opposite situation to zombie processes, referring to the case in which a
parent process terminates before its child processes, which are said to become "orphaned". Unlike the
asynchronous child-to-parent notification that happens when a child process terminates (via the
SIGCHLD signal), child processes are not notified immediately when their parent finishes. Instead, the
system simply redefines the "parent PID" field in the child process's data to be the process that is the
"ancestor" of every other process in the system, whose PID generally has the value of 1 (one), and
whose name is traditionally "init". Thus, it is said that init "adopts" every orphan process on the system.
The exec family of functions replaces the program running in a process with another program. When a
program calls an exec function, that process immediately ceases executing that program and begins
executing a new program from the beginning, assuming that the exec call doesnt encounter an error.
There shall be no return from a successful exec, because the calling process image is overlaid by the
new process image.
Problem statement:
Program:
Discussions:
Questionnaires:
Grade awarded:
Theory:
Problem statement:
Program:
Discussions:
Questionnaires:
Grade awarded: