UOS ESE Questions
UOS ESE Questions
Chapter 5 + 6 = 40 marks
Chapter 1 + 2 + 3 + 4 = 20 marks
DISADVANTAGES
1. Since the kernel does not immediately write data to the
disk for a delayed write, the system is vulnerable to
crashes that leave disk data in an incorrect state.
2. Use of the buffer cache requires an extra data copy when
reading and writing to and from user processes. When
transmitting large amounts of data, the extra copy slows
down performance.
Q7. Define zombie state. Why it is designed in lifecycle of
process?
Ans: a zombie process or defunct process is a process that has
completed execution (via the exit system call) but still has an
entry in the process table. After a child function has finished
execution, it sends an exit status to its parent function. Until
the parent function receives and acknowledges the message,
the child function remains in a “zombie” state, meaning it has
executed but not exited.
Q8. When a process terminates, the kernel performs clean-up,
assigns any children of the existing process to be adopted by
inti, and sends the death of a child signal to the parent
process. Why? / What is orphan process? Who is parent of
orphan process? Why?
Ans: When a parent process dies before a child process, the
kernel knows that it's not going to get a wait call, so instead it
makes these processes "orphans" and puts them under the
care of init (remember mother of all processes). Init will
eventually perform the wait system call for these orphans so
they can die.
Q9. What is system call? Why they are designed in OS?
Ans: A system call is a programmatic way a program requests a
service from the kernel, and strace is a powerful tool that
allows you to trace the thin layer between user processes and
the Linux kernel.
Q13. Draw the nine state diagram and show when the signals
are handled and checked? Why signals are handled and
checked on those transitions only?
Ans: When a kernel or a process sends a signal to another
process, a bit in the process table entry of that process is set,
with respect to the type of signal received. If the process is
asleep at an interruptible priority, the kernel awakens it. A
process can remember different types of signals but it cannot
remember how many times a signal of a particular type was
received.
The kernel checks for receipt of a signal when a process about
to return from kernel mode to user mode and when it enters or
leaves the sleep state at a suitably low scheduling priority. The
kernel handles signals only when a process returns from kernel
mode to user mode. This is shown in the following figure:
Q15. How many signals are there in system V UNIX? Give the
correspondence between PID and set of processes/process in
kill system call for sending the signal? Or What are the system
calls that support the processing environment in Kernel? How
Kernel uses these system calls for processing?
Ans: There are 19 signals in the System V (Release 2) UNIX
system that can be classified as follows:
Signals having to do with the termination of a process,
send when a process exits or when a process invokes the
signal system call with the death of child parameter.
If pid is -1, the kernel sends the signal to all processes
whose real user ID equals the effective user ID of the
sender (real and effective user IDs are studied later). If the
sending process has effective user ID of superuser, the
kernel sends the signal to all processes except processes 0
and 1.
If pid is a negative integer but not -1, the kernel sends the
signal to all processes in the process group equal to the
absolute value of pid.
In all cases, if the sending process does not have effective user
ID of superuser, or its real or effective user ID do not match the
real or effective user ID of the receiving process, kill fails.
Source ~ Internet {
4) Kernel- The Kernel that was related by GRUB first mount the
root file system. Then it executes init process.
Ans:
fork vfork
1
In fork() system call, child While in vfork() system call,
and parent process have child and parent process
separate memory space. share same address space.
2
The child process and Once child process is
parent process gets executed then parent
executed simultaneously. process starts its execution.
3
The fork() system call uses While vfork() system call
copy-on-write as an does not use copy-on-write.
alternative.
4
Child process does not Child process suspends
suspend parent process parent process execution in
execution in fork() system vfork() system call.
call.
5
Page of one process is not Page of one process is
affected by page of other affected by page of other
process. process.
6
There is wastage of There is no wastage of
address space. address space.
7
If child process alters page If child process alters page in
in address space, it is address space, it is visible to
invisible to parent process. parent process.
child.
Example:
in progress…..
Ans: A call to wait() blocks the calling process until one of its
child processes exits or a signal is received. After child process
terminates, parent continues its execution after wait system
call instruction. In the case of a terminated child, performing a
wait allows the system to release the resources associated with
the child; if a wait is not performed, then the terminated child
remains in a "zombie" state.
Ans: If parent process itself dies before the child process, then
child process becomes orphan. the kernel disconnects the
parent from the process tree by making process 1 (init) adopt
all its child processes. Otherwise, zombie processes would
eventually fill the maximum allowed slots of the process table.
Ans:wait() :
exec() :
This system call runs an executable file in the context of an
already running process. It replaces the previous executable
file. This is known as an overlay. The original process identifier
remains since a new process is not created but data, heap,
stack etc. of the process are replaced by the new process.
fork() :
Processes use the fork() system call to create processes that are
a copy of themselves. This is one of the major methods of
process creation in operating systems. When a parent process
creates a child process and the execution of the parent process
is suspended until the child process executes. When the child
process completes execution, the control is returned back to
the parent process.
exit() :
The exit() system call is used by a program to terminate its
execution. In a multi-threaded environment, this means that
the thread execution is complete. The operating system
reclaims resources that were used by the process after the
exit() system call.
kill() :
The kill() system call is used by the operating system to send a
termination signal to a process that urges the process to exit.
However, kill system call does not necessary mean killing the
process and can have various meanings.
in progress…..
The clock may interrupt a process several times during its time
quantum; at every clock interrupt, the clock handler increments
a field in the process table that records the recent CPU usage of
the process. Once a second, the clock handler also adjusts the
recent CPU usage of each process according to a decay
function, decay(CPU) = CPU/2; on System V. When it
recomputes recent CPU usage, the clock handler also
recalculates the priority of every process in the "preempted but
ready-to-run" state according to the formula priority=("recent
CPU usage"/2) + (base level user priority) where "base level
user priority" is the threshold priority between kernel and user
mode described above.
The transition from user mode to kernel mode occurs when the
application requests the help of operating system or an
interrupt or a system call occurs. The mode bit is set to 1 in the
user mode. It is changed from 1 to 0 when switching from user
mode to kernel mode
Q25. What is the stat system call? Enlist and explain the
various fields shown by stat system call?
Ans: The system calls stat and /stat allow processes to query
the status of files.
Stat returns information such as the file type, file owner, access
permissions, file size, number of links, inode number, and file
access times.
Q26. Enlist the function of system administrator.
Ans: in process……………...
Chapter 5
Bhushan Jadhav
main memory.
The u-area
Ans:
Unnamed pipe:
Ans
Interrupt:
Exception :
so on.
Ans :
Size of block = 1K = 2^10 Bytes
Ans :
2.process 1 (init)
Q13. Is the management of regions of process is similar to
management of inodes in kernel if yes why is it similar to
inode management
Ans :
Advantages
Disadvantages
processes
Ans: The algorithms for reading and writing disk blocks use
the algorithm getblk to allocate buffers from the pool. There
are 5 typical scenarios the kernel may follow in getblk to
allocate a buffer for a disk block.
Block could not be found on the hash queue and the free
list of buffers is empty.
maintained by kernal
Ans :
Chapter 2, 3
Subhramanya Bhat
Q1)Why various fields of u-area are required to access during
process execution?
The u area contains information that needs to be accessible
only when the process is executing. Important fields in the u
area are:
• a pointer to the process table slot of the currently
executing process
• parameters of the current system call, return values and
error codes
• file descriptors for all open files
• internal I/O parameters
• current directory and current root
• process and file size limits
The kernel internally uses a structure variable u which points to
the u area of the currently executing process. When another
process executes, the kernel rearranges its virtual address
space that u refers to the u area of the new process.
Q2)Block diag of system kernel and explain responsibility of
processes control and file control subsystem
The file subsystem accesses file data using a buffering
mechanism that regulates dataftow between the kernel . and
secondary storage devices. The buffering mechanism interacts
with block 110 device drivers to initiate data transfer to and
from the kernel. Device drivers are the kernel modules that
control the operation of peripheral devices. Block 110 devices
are random access storage devices; alternatively, their device
drivers make them appear to be random access storage devices
to the rest of the system. For example, a tape driver may allow
the kernel to treat a tape unit as a random access storage
device. The file subsystem also interacts directly with "raw" 1/0
device drivers without the intervention of a buffering
mechanism. Raw devices, sometimes called character devices,
Include all devices that are not block devices.
•The process control subsystem is responsible for process
synchronization, interprocess communication memory
management, and process scheduling. The file subsystem and
the process control subsystem interact when loading a file into
memory for execution, as will be seen in Chapter 7: the process
subsystem reads executable files into memory before executing
them
Q3)Blocks of file system layout
Ans:
Chapter 3
Q1)Five scenarios of getblk algorithm. Which scenarios are
suffered from race condition, why?
The algorithms for reading and writing disk blocks use the
algorithm getblk to allocate buffers from the pool. There are 5
typical scenarios the kernel may follow in getblk to allocate a
buffer for a disk block.
1. Block is found on its hash queue and its buffer is free.
2. Block could not be found on the hash queue, so a buffer
from the free list is allocated.
3. Block could not be found on the hash queue, and when
allocating a buffer from free list, a buffer marked "delayed
write" is allocated. Then the kernel must write the "delayed
write" buffer to disk and allocate another buffer.
4. Block could not be found on the hash queue and the free
list of buffers is empty.
5. Block was found on the hash queue, but its buffer is
currently busy.
Race condition:
It is also possible to imagine cases where a process is starved
out of accessing a
buffer In the fourth scenario, for example, if several processes
sleep while waiting
for a buffer to become free, the kernel does not guarantee that
they get a buffer in
the order that they requested one. A process could sleep and
wake. upwhen • a
buffer becomes free, only to go to sleep again because another
process got control 'of
the buffer first. Theoretically, this could go on forever, but
practically, it is not •a
problem because of the many buffer& that are typically
configured in "the system”.
Q2)In the algorithm getblk,if kernel removes a buffer from the
free list, it must raise processor priority level to block out
interrupts before checking free list, why?
The kernel raises the processor execution level to prevent disk
interrupts while
manipulating the free list, thereby preventing corruption of the
buffer pointers that
could result from a nested call to brelse . Similar bad effects
could happen if an
interrupt handler invoked brelse while a process was executing
getblk, so the kernel
raises the processor execution level at strategic places in getblk
, too.
Q3)Why free list of buffer in buffer cache is implemented like
LRU if it is like MFU what will happen.
>……………………………………………………..
Q4)Enlist advantages and disadvantages of buffer cache.
Advantages:
The use of buffers allows uniform disk access, because the
kernel does not need
to know the reason for the I/O.
Use of the buffer cache can reduce the amount of disk traffic,
thereby increasing
overall system throughput and decreasing response time.
The buffer algorithms help insure file system integrity, because
they maintain a
common, single image of disk blocks contained in the cache.
Disadvantages:
Since the kernel does not immediately write data to the disk for
a delayed write, the system is
vulnerable to crashes that leave disk data in an incorrect state.
Use of the buffer cache requires an extra data copy when
reading and writing to
and from user processes.
Q5)Suppose the Kernal does a delayed write of a block. What
happens when another process takes that block from the hash
queue, from the free list
However, it discovers that the buffer it removes from the free
list has been marked for "delayed write," so it must write the
contents of the buffer
to disk before using the buffer. The kernel starts an
asynchronous write to disk and
tries to allocate another buffer from the free list. When the
asynchronous write
completes, the kernel releases the buffer and places it at the
head of the free list
Q6)In buffer cache management why hash queue and free list
needed to maintain separately which are suitable DS for Hash
queue and free list
Each buffer always exists on a hash queue, but there is no
significance to its
position on the queue. As stated above, no two buffers may
simultaneously contain
the contents of the same disk block; therefore, every disk block
in the buffer pool
exists on one and only one hash queue and only once on that
queue. However, a
buffer may be on the free list as well if its status is free.
Because a buffer may be simultaneously on a hash queue and
on the free list, the kernel has two ways to find
it: It searches the hash queue if it is looking for a particular
buffer, and it removes
a buffer from the free list if it is looking for any free buffer.
Q7)Explain scenarios of getblk in details.
>………………………………………………………..
Q8) With diagram describe various fields of buffer header and
structure of buffer header
During system initialization, the kernel allocates space for a
number of buffers, configurable according to memory size and
performance constraints.
Two parts of the buffer:
1. a memory array that contains data from the disk.
2. buffer header that identifies the buffer.
Data in a buffer corresponds to data in a logical disk block on a
file system. A disk block can never map into more than one
buffer at a time.
The device number fields specifies the logical file system (not
physical device) and block number block number of the data on
disk. These two numbers uniquely identify the buffer. The
status field summarizes the current status of the buffer. The ptr
to data area is a pointer to the data area, whose size must be at
least as big as the size of a disk block.
The status of a buffer is a combination of the following
conditions:
• Buffer is locked / busy
• Buffer contains valid data
• Kernel must write the buffer contents to disk before
reassigning the buffer; called as "delayed-write"
• Kernel is currently reading or writing the contexts of the
buffer to disk
• A process is currently waiting for the buffer to become
free.
The two set of pointers in the header are used for traversal of
the buffer queues (doubly linked circular lists).
……………………………………………………………………………………………….
Sanket Sanatan
Q1)Write the 5 scenarios for retrieval of buffer and explain
any 4th scenario in detail.
Ans: five typical scenarios the kernel may follow in getblk to
allocate a buffer for a disk block.
1. The kernel finds the block on its hash queue, and its buffer is
free.
2. The kernel cannot find the block on the hash queue, so it
allocates a buffer from the free list.
3. The kernel cannot find the block on the hash queue and, in
attempting to allocate a buffer from the free list (as in scenario
2), finds a buffer on the free list that has been marked "delayed
write." The kernel must write the "delayed write" buffer to disk
and allocate another buffer.
4. The kernel cannot find the block on the hash queue, and the
free list of buffers is empty.
5. The kernel finds the block on the hash queue, but its buffer is
currently busy.
6. the fourth scenario, the kernel, acting for process A, cannot
find the disk block on its hash queue, so it attempts to allocate
a new buffer from the free list, as in the second scenario.
However, no buffers arc available on the free list, so process A
goes to sleep until another process executes algorithm brelse,
freeing a buffer. When the kernel schedules process A, it must
search the hash queue again for the block. It cannot allocate a
buffer immediately from the free list, because it is possible that
several processes were waiting for a free buffer and that one of
them allocated a newly freed buffer for the target block sought
by process A. Thus, searching for the block again insures that
only one buffer contains the disk block. depicts the contention
between two processes for a free buffer.
Chapter 3, 4
Shripad Deshpande
4 b)
ii)The
The super block consists of the following fields: ...
iii)The count field of file table is increased when dup() system call is
made.It decreases when close() sytem call is executed for a file.
iv) The count field of inode table increases when the number of active
instances of the file incre
increase due to open or create or dup,
h)The
The maximum number of bytes that could be held in a file is
calculated at well over 16 gigabytes, using 10 direct blocks and 1
indirect,
ct, I double indirect, and 1 triple indirect block in the inode. Given
that the file size field
ld in the inode is 32 bits, the size of a file is
effectively limited to 4 gigabytes
stat(pathname, statbuffer);
fstat(fd; statbuffer);
and statbuffer is the address of a data structure in the user process that
will contain the status information of the file on completion of the call.
The system calls simply write the fields of the inode into statbuffer
Chapter 2,3
Chetan Pukale
Q1 In the algorithm getblk, if kernel removes a buffer from
free list, it must raise the process priority level to block out
interrupts before checking free list. Why?
Ans:-Because handling the interrupt could corrupt the pointers
Q2)What are the system calls that support the processing
environment in kernel? How kernel uses these system calls for
processing?
Ans: System call supported by processing unit:-
1)fork() 2)exec() 3)brk() 4)exit() 5)wait() 6)signal() 7)kill()
8)signal()
fork : create a new process
exit : terminate process execution
wait : allow parent process to synchronize its execution with
the exit of a child process
exec : invoke a new program
brk : allocate more memory dynamically
signal : inform asynchronous event
Q3-Draw and elaborate the blocks of file system layout. Which
block help to find maximum number files/directory user can
create? Which block gives information about state of file
system?
Ans: Superblock is responsible for how many files user can
write
Superblock represent state of table.
Q4. With block diagram explain System Kernel and enlist the
responsibilities of process control subsystem and file
subsystem.
Ans: