Documente Academic
Documente Profesional
Documente Cultură
OS & CS3009
(CSE/IT/CSSE/CSCE)
SECTION-A
1. [1 10]
(a) Write the actions taken by a kernel to context-switch between processes.
Ans:
The Actions taken by a kernel to context-switch between processes are:
The OS must save the status of current execution process into its PCB.
The scheduler is invoked to determine the next process to be executed.
Then the information related to the selected process is retrieved from its PCB
into the corresponding registers.
(b) What is the number of child processes created by the following code:
int i;
for(i=0; i<3; i++)
fork( );
fork( );
Ans:15
(c) A counting semaphore S is initialized to 10. Then 6 WAIT operations and 4
SIGNAL operations were completed on this semaphore. What would be the
resulting value of S?
Ans: 8
(d) Name two CPU scheduling policy where context-switching does not occur.
Ans:
1. First Come First Served 2. Shortest Job First
(e) A system is having 3 user processes P1, P2 and P3 where P1 requires 2 units of
resource R, P2 requires 3 units of resource R, P3 requires 4 units of resource R.
What is the minimum number of units of R that ensures no deadlock in the
system?
Ans:
7 no. resources
(f) Define Highest Response ratio Next scheduling policy with its advantage.
Ans:
Highest Response ratio Next scheduling policy :
1. Out of all the available processes, CPU is assigned to the process having highest
response ratio. Response Ratio (RR) for any process is calculated by using the
formula-
Response Ratio=(Waiting time+Burst time)/Burst_time
KIIT-DU/2019/SOT/Autumn End Semester Examination-2019 KIIT-DU/2019/SOT/Autumn End
Semester Examination-2019
2. In case of a tie, it is broken by FCFS Scheduling.
3. It operates only in non-preemptive mode.
Advantages:
It performs better than SJF Scheduling.
It not only favors the shorter jobs but also limits the waiting time of longer jobs
which avoids starvation.
(g) Write the difference between thread and process.
Ans:
Difference between Process and Thread:
S.N
O PROCESS THREAD
Process means any program is in Thread means segment of a
1. execution. process.
Process takes more time to Thread takes less time to
2. terminate. terminate.
3. It takes more time for creation. It takes less time for creation.
It also takes more time for It takes less time for context
4. context switching. switching.
(h) What is a safe state in deadlock detection?
Ans:
A state is safe if the system can allocate all resources requested by all processes
( up to their stated maximums) without entering a deadlock state.
More formally, a state is safe if there exists a safe sequence of processes { P1,
P2,….. Pn} such that all of the resource requests for Pi can be granted using the
resources currently allocated to Pi and all processes Pj where j<i.(i.e., if all the
processes prior to Pi finish and free up their resources, then Pi will be able to
finish also, using the resources that they have freed up.)
(i) Define latency and seek time with respect to disk I/O.
Ans:
Rotational delay or latency is the time it takes for the beginning of the required
sector to reach the head.
Seek time is the time required to move the disk arm to the required track.
(j) Describe the purpose of device driver.
Ans:
Device Drivers are the software through which, the kernel of a computer
communicates with different hardware, without having to go into the details of
how the hardware works. The purpose of device drivers is to allow smooth
functioning of the hardware for which it is created and to allow it to be used with
different operating systems.
SECTION-B
2. (a) What is meant by domain of protection? How is it implemented by the operating [4]
system?
Ans: (first part 1.5 & second part 2.5)
A protection domain specifies the resources that a process may access.
Each domain defines a set of objects and the types of operations that may be invoked
on each object. An access right is the ability to execute an operation on an object.
3. (a) Consider the following set of processes, with the length of the CPU-burst time given [4]
in milliseconds:
Process Burst time Arrival time
P0 3 0
P1 6 2
P2 4 4
P3 5 6
P4 2 8
The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time
0.
i. Draw Gantt charts illustrating the execution of these processes using shortest
remaining time first and Round Robin (quantum = 2ms) scheduling.
ii. What is the turnaround time and the waiting time of each process for each of the
scheduling algorithms in part a?
Ans: ( 1 mark each for Gantt of SRTF & RR, 0.5 mark each for calculation turn
around time & waiting time in SRTF and 0.5 mark each for calculation turn
around time & waiting time in RR )
SECTION-C
4. (a) Explain 1st readers-writers problem and write its solution using semaphore. [4]
Ans: ( Explanation 1 mark, reader algorithm 2 marks, writer algorithm 1 mark )
(b) If the virtual address space is represented by 32 bits, the page size is 4Kbyte, the size [4]
of the physical memory is 64Mbyte and only 2 bits are used as control bits, calculate
the size of the page table.
Ans: ( step marking decided by examiner )
I-node is a data structure that keeps track of all the information about a file. We keep
our information in a file and the OS stores the information about a file in an I-node.
Data structures that contain information about files in UNIX file systems that are
created when a file system is created. Each file has an I-node and is identified by an I-
node number (I-number) in the file system where it resides. I-nodes provide important
information on files such as user and group ownership, access mode (read, write,
KIIT-DU/2019/SOT/Autumn End Semester Examination-2019 KIIT-DU/2019/SOT/Autumn End
Semester Examination-2019
execute permissions) and type.
The I-node contains the following pieces of information:
• Mode/permission (protection)
• Owner ID
• Group ID
• Size of file
• Number of hard links to the file
• Time last accessed
• Time last modified
• Time I-node last modified
When a file is created inside a directory then the file-name and I-node number are
assigned to file. These two entries are associated with every file in a directory. The
user might think that the directory contains the complete file and all the extra
information related to it but this might not be the case always. So we see that a
directory associates a file name with its I-node number.
When a user tries to access the file or any information related to the file then he/she
uses the file name to do so but internally the file-name is first mapped with its I-node
number stored in a table. Then through that I-node number the corresponding I-
node is accessed. There is a table (I-node table) where this mapping of I-node
numbers with the respective I-nodes is provided.
SECTION-D
7.
(a) Explain various File allocation methods and compare them with respect to space and [4]
time.
Ans: ( Description of three file allocation methods 1 mark each, comparison 1
mark )
The allocation methods define how the files are stored in the disk blocks. There are
three main disk space or file allocation methods.
1. Contiguous Allocation
2. Linked Allocation
3. Indexed Allocation
The main idea behind these methods is to provide:
Efficient disk space utilization.
Fast access to the file blocks.
All the three methods have their own advantages and disadvantages as discussed
below:
Contiguous Allocation
In this scheme, each file occupies a contiguous set of blocks on the disk. For
example, if a file requires n blocks and is given a block b as the starting location, then
the blocks assigned to the file will be: b, b+1, b+2,……b+n-1. This means that given
the starting block address and the length of the file (in terms of blocks required), we
KIIT-DU/2019/SOT/Autumn End Semester Examination-2019 KIIT-DU/2019/SOT/Autumn End
Semester Examination-2019
can determine the blocks occupied by the file.
The directory entry for a file with contiguous allocation contains address of starting
block and Length of the allocated portion. The file ‘mail’ in the following figure starts
from the block 19 with length = 6 blocks. Therefore, it occupies 19, 20, 21, 22, 23,
24 blocks.
Advantages:
Both the Sequential and Direct Accesses are supported by this. For direct access,
the address of the kth block of the file which starts at block b can easily be obtained
as (b+k).
This is extremely fast since the number of seeks are minimal because of contiguous
allocation of file blocks.
Disadvantages:
This method suffers from both internal and external fragmentation. This makes it
inefficient in terms of memory utilization.
Increasing file size is difficult because it depends on the availability of contiguous
memory at a particular instance.
Advantages:
This is very flexible in terms of file size. File size can be increased easily since the
system does not have to look for a contiguous chunk of memory.
This method does not suffer from external fragmentation. This makes it relatively
better in terms of memory utilization.
Disadvantages:
Because the file blocks are distributed randomly on the disk, a large number of
KIIT-DU/2019/SOT/Autumn End Semester Examination-2019 KIIT-DU/2019/SOT/Autumn End
Semester Examination-2019
seeks are needed to access every block individually. This makes linked allocation
slower.
It does not support random or direct access. We can’t directly access the blocks of a
file. A block k of a file can be accessed by traversing k blocks sequentially
(sequential access) from the starting block of the file via block pointers.
Pointers required in the linked allocation incur some extra overhead.
3. Indexed Allocation
In this scheme, a special block known as the Index block contains the pointers to all
the blocks occupied by a file. Each file has its own index block. The ith entry in the
index block contains the disk address of the ith file block. The directory entry contains
the address of the index block as shown in the image:
Advantages:
This supports direct access to the blocks occupied by the file and therefore provides
fast access to the file blocks.
It overcomes the problem of external fragmentation.
Disadvantages:
The pointer overhead for indexed allocation is greater than linked allocation.
For very small files, say files that expand only 2-3 blocks, the indexed allocation
would keep one entire block (index block) for the pointers which is inefficient in
terms of memory utilization. However, in linked allocation we lose the space of
only 1 pointer per block.
(b) Consider a disk system with 3000 cylinders, numbered 0 to 2999. The drive is [4]
currently serving a request at cylinder 143, and the previous request was at cylinder
125. The requests to access the cylinders occur in the following sequence:
86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130.
Starting from the current head position, evaluate the time taken to satisfy all the
requests using shortest seek time first policy if it takes 1ms to move from one cylinder
to adjacent one? Also show the total head movement (in cylinders) for servicing the
request for C-SCAN and C-LOOK policy?
Ans:(SSTF with seek time calculation 2 marks, C-SCAN, C-LOOK 1 mark each )
The paper setter /Moderator will provide mapping of Question with Course Outcomes and learning levels in
the following format:
CO1 Able to understand the difference between different types of modern operating
systems, virtual machines and their structure of implementation and applications.
CO2 Able to understand the difference between process & thread, issues of scheduling of
user-level processes/threads and their issues & use of locks, semaphores, monitors for
synchronizing multiprogramming with multithreaded systems and implement them in
multithreaded programs.
CO3 Able to understand the concepts of deadlock in operating systems and how they can
be managed/avoided and implement them in multiprogramming system.
CO4 Able to understand the design and management concepts along with issues and
challenges of main memory, virtual memory and file system.
CO5 Able to understand the types of I/O management, disk scheduling, protection and
security problems faced by operating systems and how to minimize these problems.
CO6 Able to familiar with various types of operating systems such as Unix.
Biswajit Sahoo
Signature of Paper Moderator