OSY Winter 23
OSY Winter 23
a) Define real time operating system, along with any two applications of it.
Ans.Real time Operating System:
A real time system has well defined fixed time constraints. Processing
should be done within the defined constraints -Hard and Soft real time
system.
OR
The real-time operating system used for a real-time application means
for those applications where data processing should be done in the fixed
and small quantum of time.
Types of real time operating system
1. Hard real-time
2. Soft real-time
Applications:
1. Flight Control System
2. Simulations
3. Industrial control
4. Military applications
c) Draw neat labelled process state diagram along with the correct directions of arrows.
Ans.
Segmentation is a memory management scheme that permits dividing logical address space into
multiple segments.
OR
Segmentation divides the Computer's physical memory and program's address space into
segments.
f) What is the use of PS command? Write long forms of UID, PID in the output of this
command.
Ans.ps command:It is used to display the characteristics of a process.
This command is used to list the processes associated with a user at a particular terminal.
UID - (Owner) User-id
PPID - Parent Process-id
Advantages
Increased reliability: Due to the multiprocessing system, processing tasks can be
distributed among several processors. This increases reliability as if one processor fails;
the task can be given to another processor for completion.
Increased throughout: As several processors increase, more work can be done in less
time.
The economy of Scale: As multiprocessors systems share peripherals, secondary storage
devices, and power supplies, they are relatively cheaper than single-processor systems.
Reduce Cost
In this, all processes who want to communicate with other processes can access a region
of the memory residing in an address space of a process creating a shared memory
segment.
All the processes using the shared memory segment should attach to the address space
of the shared memory. All the processes can exchange information by reading and/or
writing data in shared memory segment.
The form of data and location are determined by these processes who want to
communicate with each other.
These processes are not under the control of the operating system.
The processes are also responsible for ensuring that they are not writing to the same
location simultaneously.
After establishing shared memory segment, all accesses to the shared memory segment
are treated as routine memory access and without assistance of kernel.
c) Describe concept of free space management technique using bit map method.
Ans.Bit Map:
The free-space list is implemented as a bit map or bit vector.
Each block is represented by 1 bit. If the block is free, the bit is 1; if the block is allocated, the bit
is 0.
For example, consider a disk where blocks 2, 3, 4, 5, 8, 9, 10, 11, 12, 13 are free and the rest of
the blocks are allocated.
The free-space bit map would be : 0011110011111100
c) Explain working of CPU switch from process to process with neat labelled diagram.
Ans.A CPU switch from process to process is referred as context switch.
A context switch is a mechanism that store and restore the state or context of a CPU in Process
Control block so that a process execution can be resumed from the same point at a later time.
When the scheduler switches the CPU from one process to another process, the context switch
saves the contents of all process registers for the process being removed from the CPU, in its
process control block.Context switch includes two operations such as state save and state restore.
State save operation stores the current information of running process into its PCB. State restore
operation restores the information of process to be executed from its PCB. Switching the CPU
from one process to another process requires performing state save operation for the currently
executing process (blocked) and a state restore operation for the process ready for execution.
This task is known as context switch.
B) User management:
ï‚· User management includes everything from creating a user to
deleting a user on your system. User management can be done
in three ways on a Linux system.
ï‚· Command line tools include commands like useradd, userdel,
usermod, passwd, etc. These are mostly used by the server
administrators.
Useradd: With useradd commands you can add a user.
Syntax: useradd -m -d /home/<userName> -
c "<userName>" <userName>
Example: useradd -m -d /home/xyz -c "xyz" xyz
File /etc/default/useradd contains some user default options.
The command useradd -D can be used to display this file.
Syntax: useradd -D
Userdel: To delete a user account userdel command is used.
Syntax: userdel -r <userName>
Usermod: The command usermod is used to modify the properties of
an existing user.
Syntax: usermod -c <'newName'> <oldName>
Example: usermod -c 'vppoly' john
Using passwd command
Passwd: A user can set the password with the command passwd. Old
password has to be typed twice before entering the new one.
Syntax: passwd <userName>
Example: passwd vppoly
C) Performance Monitor:
It is very tough job for every system or network administrator to
monitor and debug Linux System Performance problems every day.
The commands discussed below are some of the most fundamental
commands when it comes to system analysis and debugging Linux
server issues such as:
1) vmstat: Virtual memory statistics
The vmstat command reports information about processes, memory,
paging, block IO, traps, and cpu activity.
$ vmstat 3
2)top: Process activity monitoring command top command display Linux processes. It provides
a dynamic real-time
view of a running system i.e. actual process activity. By default, it
displays the most CPU-intensive tasks running on the server and
updates the list every five seconds.
$ top
3) free: Show Linux server memory usage
free command shows the total amount of free and used physical and
swap memory in the system, as well as the buffers used by the kernel.
# free
4) iostat: Montor Linux average CPU load and disk activity
iostat command report Central Processing Unit (CPU) statistics and
input/output statistics for devices, partitions and network filesystems
(NFS).
# iostat
5) netstat Linux network and statistics monitoring tool
netstat command displays network connections, routing tables,
interface statistics, masquerade connections, and multicast
memberships.
# netstat –tulpn
b) Differentiate between process and thread (any two points). Also discuss the benefits of
multithreaded programming.
Ans.
Comparis Process Thread
on Basis
Definition A process is a program under A thread is a lightweight process that can
execution i.e. an active program. be managed independently by a scheduler
Context Processes require more time for Threads require less time for context
switching context switching as they are heavier. switching as they are lighter than
time processes.
Memory Processes are totally independent and A thread may share some memory with its
Sharing don’t share memory. peer threads.
Communic Communication between processes Communication between threads requires
ation requires more time than between less time than between processes.
threads.
Blocked If a process gets blocked, remaining If a user level thread gets blocked, all of
processes can continue execution. its peer threads also get blocked.
Resource Processes require more resources than Threads generally need less resources
Consumpti threads. than processes.
on
Dependen Individual processes are independent Threads are parts of a process and so are
cy of each other. dependent.
Data and Processes have independent data and A thread shares the data segment, code
Code code segments. segment, files etc. with its peer threads.
sharing
Treatment All the different processes are treated All user level peer threads are treated as a
by OS separately by the operating system. single task by the operating system.
Time for Processes require more time for Threads require less time for creation.
creation creation.
Time for Processes require more time for Threads require less time for termination.
terminatio termination.
n
We can find the free block number from the bit vector using the following method-
Block number = (Number of bits per word )* (number of 0-value
words) + (offset of first bit)
We will now find the first free block number in the above example.
The first group of 8 bits (00111100) constitutes a non-zero word since all bits are not 0. After
finding the non-zero word, we will look for the first 1 bit. This is the third character of the non-
zero word. Hence,
offset = 3.
Therefore, the first free block number = 8 * 0 + 3 = 3.
Linked List:
Another method of doing free space management in operating systems is a linked list. In this
method, all the free blocks existing in the disk are linked together in a linked list. The address of
the first free block is stored somewhere in the memory. Each free block contains a pointer that
contains the address to the next free block. The last free block points to null, indicating the end
of the linked list.
For example, consider a disk having 16 blocks where block numbers 3, 4, 5, 6, 9, 10, 11, 12, 13,
and 14 are free, and the rest of the blocks, i.e., block numbers 1, 2, 7, 8, 15 and 16 are allocated
to some files. If we maintain a linked list, then Block 3 will contain a pointer to Block 4, and Block
4 will contain a pointer to Block 5.
Grouping: The third method of free space management in operating systems is grouping. This
method is the modification of the linked list method. In this method, the first free block stores the
addresses of the n free blocks. The first n-1 of these blocks is free. The last block in these n free
blocks contains the addresses of the next n free blocks, and so on.
For example, consider a disk having 16 blocks where block numbers 3, 4, 5, 6, 9, 10, 11, 12, 13,
and 14 are free, and the rest of the blocks, i.e., block numbers 1, 2, 7, 8, 15 and 16 are allocated
to some files.
If we apply the Grouping method considering n to be 3, Block 3 will store the addresses of Block
4, Block 5, and Block 6. Similarly, Block 6 will store the addresses of Block 9, Block 10, and Block
11. Block
11 will store the addresses of Block 12, Block 13, and Block 14. This is also represented in the
following figure
Advantages
Since it is a single directory, so its implementation is very easy.
If the files are smaller in size, searching will become faster.
The operations like file creation, searching, deletion, updating are very easy in such a
directory structure.
Logical Organization : Directory structures help to logically organize files and
directories in a hierarchical structure. This provides an easy way to navigate and manage
files, making it easier for users to access the data they need.
Increased Efficiency: Directory structures can increase the efficiency of the file system
by reducing the time required to search for files. This is because directory structures are
optimized for fast file access, allowing users to quickly locate the file they need.
Improved Security : Directory structures can provide better security for files by allowing
access to be restricted at the directory level. This helps to prevent unauthorized access to
sensitive data and ensures that important files are protected.
Facilitates Backup and Recovery : Directory structures make it easier to backup and
recover files in the event of a system failure or data loss. By storing related files in the
same directory, it is easier to locate and backup all the files that need to be protected.
Scalability: Directory structures are scalable, making it easy to add new directories and
files as needed. This helps to accommodate growth in the system and makes it easier to
manage large amounts of data.
Disadvantages
There may chance of name collision because two files can have the same name.
Searching will become time taking if the directory is large.
This can not group the same type of files together.
2) Two-Level Directory
As we have seen, a single level directory often leads to confusion of files names among different
users. The solution to this problem is to create a separate directory for each user.
In the two-level directory structure, each user has their own user files directory (UFD). The
UFDs have similar structures, but each lists only the files of a single user. System’s master file
directory (MFD) is searched whenever a new user id is created.
The main advantage is there can be more than two files with same name, and would be
very helpful if there are multiple users.
A security would be there which would prevent user to access other user’s files.
Searching of the files becomes very easy in this directory structure.
Disadvantages
As there is advantage of security, there is also disadvantage that the user cannot share
the file with the other users.
Unlike the advantage users can create their own files, users don’t have the ability to
create subdirectories.
Scalability is not possible because one user can’t group the same types of files together.
3) Tree Structure/ Hierarchical Structure
Tree directory structure of operating system is most commonly used in our personal
computers. User can create files and subdirectories too, which was a disadvantage in the
previous directory structures.
This directory structure resembles a real tree upside down, where the root directory is at the
peak. This root contains all the directories for each user. The users can create subdirectories and
even store files in their directory.
A user do not have access to the root directory data and cannot modify it. And, even in this
directory the user do not have access to other user’s directories. The structure of tree directory
is given below which shows how there are files and subdirectories in each user’s directory.
Advantages
This directory structure allows subdirectories inside a directory.
The searching is easier.
File sorting of important and unimportant becomes easier.
This directory is more scalable than the other two directory structures explained.
Disadvantages
As the user isn’t allowed to access other user’s directory, this prevents the file sharing
among users.
As the user has the capability to make subdirectories, if the number of subdirectories
increase the searching may become complicated.
Users cannot modify the root directory data.
If files do not fit in one, they might have to be fit into other directories.