Winter 2023
Winter 2023
Winter 2023
Page 1 / 27
Page 2 / 27
Ans.
Correct
diagram
2M
Page 3 / 27
Page 4 / 27
MEMORY PERIPHERALS
OR
Page 5 / 27
Deciding which processes (or parts thereof) and data to move into
and out of memory.
Allocating and deallocating memory space as needed.
Managing swap spaces, which store inactive pages of memory.
Implementing policies for memory allocation.
File Management:
The creation and deletion of files.
The creation and deletion of directory
The support of primitives for manipulating files and directions.
The mapping of files onto secondary storage.
The backup of files on stable storage media.
Adding and editing the data in files.
Moving files from one location to another.
Store, arrange, or accessing files on a disk or other storage
locations.
c) Explain shared memory method of IPC using neat labelled 4M
diagram
Ans. Inter-process communication: Cooperating processes require an Explanatio
Inter- process communication (IPC) mechanism that will allow them n
to exchange data and information. 3M,
diagram
1M
Page 6 / 27
Page 7 / 27
Explanatio
ii)Sleep n½M
Syntax: sleep NUMBER[SUFFIX]
The sleep command pauses the execution for specified time in
command.
iii)Wait
Syntax: wait [pid]
Wait command waits for running process to complete and return the
exit status.
iv) Exit
Syntax: exit
used to quit the shell
(OR)
Syntax: exit[n]
The terminal window will close and return a status of n
b) What is deadlock? Discuss any one method of deadlock 4M
prevention
Ans. A deadlock is a situation where a set of processes are blocked
because each process is holding a resource and waiting for another Deadlock
resource acquired by some other process. definition
Methods for deadlock prevention (Any 1) 1M
1. Eliminate Mutual Exclusion:
The mutual-exclusion condition must hold for non-sharable Any 1
method
resources.
3M
Mutual section from the resource point of view is the fact that a
resource can never be used by more than one process simultaneously
which is fair enough but that is the main reason behind the deadlock.
If a resource could have been used by more than one process at the
same time then the process would have never been waiting for any
resource.Read-only files are a good example of a sharable resource. If
several processes attempt to open a read-only file at the same time,
they can be granted simultaneous access to the file.
Page 8 / 27
3. Eliminate No Preemption:
If a process that is holding some resources requests another resource
that cannot be immediately allocated to it, then all resources currently
being held are preempted. That is this resources are implicitly
released. The preempted resources are added to the list of resources
for which the process is waiting. Process will be restarted only when
all the resources i.e. its old resources, as well as the new ones that it is
requesting will be available.Preemption ensures that resources are
efficiently utilized and prevents deadlocks caused by the hold and
wait condition.
Page 9 / 27
0 0 1 1 1 1 0 0 1 1 1 1 1 1 0 0
The main advantage of this approach is its relative simplicity and its
efficiency in findingthe first free block or n consecutive free blocks
on the disk.
d) Draw the diagram of linked file allocation method and explain it. 4M
Linked Allocation:
Ans. This allocation is on the basis of an individual block. Each block
contains a pointer to the next block in the chain. Correct
Diagram
In this scheme, each file is a linked list of disk blocks which need 2M
not be contiguous. The disk blocks can be scattered anywhere on
the disk. Explanatio
n 2M
The directory contains a pointer to the first and the last blocks of
the file.
Page 10 / 27
Space is required for the pointers, 1.5% of disk is used for the
pointers and not for information. If a pointer is lost or damaged or
bug occurs in operating system or disk hardware failure occur, it
may result in picking up the wrong pointer.
Page 11 / 27
Ans. Any 4
COMMAND LINE GRAPHIC USER points 1M
INTERFACE (CLI) INTERFACE (GUI) each
Page 12 / 27
Page 13 / 27
Page 14 / 27
Gantt Chart
Ans.
Gantt
chart
2M,
FCFS
Waiting time Average
P0=0 waiting
P1= (10-1) = 9 time
P2= (39-2) = 37 calculation
P3= (42-3) = 39 1M,
P4= (49-4) = 45
Average Waiting time = Waiting time of all processes / Number of
processes Average
= (0+9+37+39+45)/5 = 26 ms turnaroun
Turnaround Time d time
calculation
P0=10
1M
P1=39-1=38
P2=42-2=40
P3=49-3=46
P4=61-4=57
Average Turnaround time = Turnaround time of all processes /
Number of processes
= (10+38+40+46+57)/5
= 191/5
= 38.2 ms
Page 15 / 27
First Fit: Allocate the Best Fit: Allocate the Worst fit: Allocate
Ans. first free block to the smallest free block the largest free block Any
new process that is big enough to to the new process Correct
accommodate new representat
OS process OS ion 4M
4 KB OS 4 KB
<FREE> 1 4 KB 9 KB
KB 9 KB <FREE>
8 KB 20 KB 12 KB
16 KB 8 KB
20 KB
16 KB <FREE> 0 16 KB
8 KB KB 8 KB
2 KB 8 KB 2 KB
6 KB 2 KB 6 KB
6 KB
OR
First Fit: Allocate the Best Fit: Allocate the Worst fit: Allocate
first free block to the smallest free block the largest free block
new process that is big enough to to the new process
accommodate new
process
OS OS OS
4 KB 4 KB 4 KB
9 KB 9 KB 9 KB
20 KB 20 KB 20 KB
16 KB 16 KB 16 KB
8 KB 8 KB 8 KB
2 KB 2 KB 2 KB
6 KB 6 KB 6 KB
Page 16 / 27
- Use Secure SSH: Telnet and rlogin protocols uses plain text, not
encrypted format which is the security breaches. SSH is a secure
protocol that use encryption technology during communication with
server. Never login directly as root unless necessary. Use “sudo” to
execute commands.
$ vi /etc/ssh/sshd_config
$ PermitRootLogin no #disable root login
$AllowUsers username # Allow only specific users
$ Protocol 2 #use SSH protocol 2 version
Turn Off IPv6: If you are not using a IPv6 protocol, then you should
disable it because most of the applications or policies not required
IPv6 protocol and currently it doesn’t required on the server. Go to
network configuration file and add followings lines to disable it.
# vi /etc/sysconfig/network
NETWORKING_IPV6=no
IPV6INIT=no
Page 17 / 27
Page 18 / 27
Page 19 / 27
Resource sharing:
Processes may only share resources through techniques such as
shared memory or message passing. Such techniques must be
explicitly arranged by the programmer. However, threads share the
memory and the resources of the process to which they belong by
default. The benefit of sharing code and data is that it allows an
application to have several different threads of activity within the
same address space.
Economy:
Allocating memory and resources for process creation is costly.
Because threads share the resources of the process to which they
belong, it is more economical to create and context-switch threads.
Empirically gauging the difference in overhead can be difficult, but in
general it is much more time consuming to create and manage
processes than threads. In Solaris, for example, creating a process is
about thirty times slower than is creating a thread, and context
switching is about five times slower.
Scalability:
The benefits of multithreading can be greatly increased in a
multiprocessor architecture, where threads may be running in parallel
on different processors. A single-threaded process can only run on
one processor, regardless how many are available. Multithreading on
a multi-CPU machine increases parallelism.
Page 20 / 27
Ans. i) LRU:
Considering frame size is 3: LRU
3M
ii) Optimal:
Considering Frame size is 3:
Optimal
3M
Reason
2M
Pre-
Following are the reason, why pre-emptive scheduling is better emptive
Ans. than non pre-emptive scheduling: SJF
Preemptive scheduling is quite flexible because critical processes 2M
are allowed to access the CPU because they come in the ready
queue and no matter which process is currently running. Non- NonPre-
preemptive scheduling is tough because if an essential process is emptive
assigned to the ready queue, the CPU process is not be SJF
2M
interrupted.
Page 21 / 27
Page 22 / 27
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
Page 23 / 27
Page 24 / 27
Page 25 / 27
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.
Searching is very easy.
There can be two files with the same name in two different user
directories. Since they are not in the same directory, the same
name can be used.
Grouping is easier.
A user cannot enter another user’s directory without permission.
Implementation is easy.
It does not allow users to create subdirectories.
Page 26 / 27
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.
•The root directory is highly secured, and only the system
administrator can access it. We can see how there can be
subdirectories inside the user directories. A user cannot modify the
root directory data. Also, a user cannot access another user's
directory.
•Allows subdirectories inside a directory.
•Searching is easy.
•Allows grouping.
•Segregation of important and unimportant files is easy.
•As one user cannot enter another user’s directory, this restricts
sharing of files.
•Too many subdirectories may make the search complicated.
•Users cannot modify the root directory’s data.
Page 27 / 27