You are on page 1of 14

OPERATING SYSTEM

1. What is meant by a system call?


A system call instructs the kernel to do various operations for the calling
process and exchange data between the kernel and the process. Process can
directly access the kernel, only through system calls. he set of system calls
defines the programming interface offered by the kernel to user process.
!. What is called bootstrap?
"ootstrap is a procedure of booting the system by placing the copy of the
kernel in the systems main memory and to start executing it.
#. What are the events that cause the system to enter into kernel mode?
$evice interrupts
%oftware interrupts
&xceptions
'. $istinguish between interrupts and exceptions.
Interrupts Exceptions
(nterrupts are asynchronous
events caused by peripheral
devices such as disks,
terminals etc.
(t re)uires rapid servicing.
(t must not be blocked, except
while the process accessing
the critical regions.
&xceptions are synchronous
events to the process and are
caused by process itself, such as
dividing by *ero.
$oesn+t re)uire rapid servicing.
(t can be blocked.
,. What are signals?
%ignals are used to inform a process of asynchronous events and to handle
exceptions.
-. What is meant by scheduler?
%cheduler is the component of the operating system that determines which
process to run at any given time and for how long it should run. he primary
functions of the scheduler are to decide when to perform a context switch and
which process to run.
.. What is meant by dispatch latency?
$ispatch latency is the delay between the time when any process become
runnable and the time they actually begin running.
/. What is meant by preemption point?
Preemption point is a place in the kernel code, where all the kernel data
structures are in steady or stable state and the kernel is about to do some
lengthy computation. 0ernels may have several preemption points.
1. 2ow real3time processes are different from time3sharing process?
Real-time process Time-sharing process
he dispatch latency time
should be minimum as
much as possible.
he response time should be
good enough.
&xceptions should be
handled neatly.
hey have fixed priority and
time )uantum.
4o need to concentrate
on this issue too much.
4eed not be.
4eed not be.
hey don+t have any
fixed priority and time )uantum.
15. rue real3time system should have 66666666 type kernel, so that it can
achieve 6666666666.
Ans: 7ully preemptible kernel, good response time.
11. What is meant by symmetric multiprocessing and asymmetric multiprocessing
system?
(n symmetric multiprocessing system, all the 8P9+s are treated e)ually.
he kernel code is shared by all the 8P9+s and any 8P9 can access any part
of the kernel code. Any 8P9 can run any kernel process or user process at
any given time.
:n the other hand, in asymmetric multiprocessing system, all the 8P9+s
are not treated e)ually. (ndividual subsystems are allocated to individual
processors and one processor cannot access the subsystem allocated to another
processor.
1!. What are the three types of multiprocessing system?
;aster3slave
Asymmetric
%ymmetric
1#. What is meant by master3slave multiprocessing system?
(n this system, a single processor is given more control <called master= and
it is responsible for controlling other processors <called slaves=. (t is
asymmetric in nature.
1'. 2ow are the applications classified?
(nteractive
"atch
>eal3time applications
1,. What is the need for the classification of application with respect to
scheduling?
(n the case of interactive applications, the scheduling goal is to reduce
the average time and variance between the user action and application
response. &.g. &ditors, ?9(.
he background @obs are referred to as batch applications. 2ere the
goal is to reduce the task+s computation time and throughput in the
presence of other activities.
ime3critical applications are referred to as real3time applications. he
goal is to have the guaranteed response times.
1-. What is a semaphore?
A semaphore is n integer3valued ob@ect that have two atomic operations
defined <i.e.= P<= and A<=. he P<= operation decrements the value of a
semaphore if its value is greater than 5 and the A<= operation increment its
value. (f the resulting value becomes greater than or e)ual to *ero the A<=
operation wakes up a process.
1.. What is meant by inter3process communication?
(n a complex programming environment, many processes will be
communicating with each other to share resources and information and the
kernel provides necessary mechanisms to achieve this goal. hese
mechanisms are collectively referred to as inter3process communications.
1/. What are the distinct purposes of using inter3process communication?
$ata transfer
>esource sharing
$ata sharing
&vent notification
Process control
11. 666666666 provides the fastest mechanism for processes to share data.
Ans: %hared memory.
!5. What are the services offered by semaphores?
(t can provide mutual exclusion on a resource.
(t can be used to wait for an event.
(t can be used for allocating countable resource.
!1. What is the advantage of using semaphore over the sleepBwakeup techni)ue?
(n sleepBwakeup techni)ue, when a process releases the resource held by it,
it wakes up all the processes waiting for the resource to become free, even
though only one process can ac)uire the resource. herefore, it is unnecessary
to wake up all the processes.
"ut by using semaphore, when a process wakes up with in a P<= operation,
the woken up process is guaranteed to have the resource. (t also ensures that
the ownership is completely transferred to the woken up process and hence in
the mean time if any other process tries to ac)uire the resource, it cannot be
able to do so.
!!. What is meant by a spin lock?
A spin lock is a scalar variable which is used as the simplest locking
primitive. (f any resource is protected by spin lock, processes trying to
ac)uire the resource will busy3wait, until the resource is unlocked. (t is also
known as simple lock or a simplex mutex.
!#. (s it advisable to use spin locks at all situations?
4o. (t is advisable to use the spin locks only when the process holding
spin lock executes for extremely shorter duration because the processor gets
ties up by the executing process, while waiting for the lock to be released.
!'. What is meant by a condition variable?
A condition variable is a variable associated with a predicate based on
some shared data. (t allows processes to block on it and provides facilities to
wake up one or more blocked process, when the result of the predicate
changes. (t is more useful for waiting on events than for resource locking.
!,. What is meant by read3write lock?
>ead3write lock is a complex lock, which permits both shared and
exclusive access modes for resources and is built on top of the simple locks
and conditions. (t may permit either a single writer or multiple readers.
!-. What are the two distinct types of multitasking?
Process3based multitasking
hread3based multitasking
!.. "riefly explain about the sleepBwakeup mechanism involved in
synchroni*ation.
he sleepBwakeup mechanism involves the locked and wanted flags with
shared resources. When a process wants to access a sharable resource, it first
checks its locked flag. (f the flag is clear, then the process sets the locked flag
and proceeds to use the resource. (f any other process wants to access the
same resource, it first checks the locked flag and since it is set, it will go to
sleep after setting the wanted flag associated with the resource. When the first
process finished using the resource it will clear the locked flag and wakes up
the processes waiting for the resource to become free, by checking the wanted
flag.
!/. "riefly explain about lost3wakeup problem?
(n multiprocessor system, let us consider a process A has locked a
resource. Another process " running on another processor tries to ac)uire the
same resource and finds it locked. 2ence process " calls the sleep<= function
to wait for the resource become free. "etween the time " finds the resource
locked and the time it calls the sleep<= function, the process A release the
resource and wakes up all the processes blocked on it. %ince " has not yet put
on the sleep )ueue, it will miss the wake up and hence even though the
resource is not locked and if no other processes try to ac)uire the resource, the
process " could block indefinitely. his is known as lost3wakeup problem.
!1. What is meant by thundering herd problem?
(n a multiprocessor system, consider a resource is held by any process A.
%everal processes could be blocked on a resource which was held by process
A. When the process A finishes using the resource, it calls wakeup<=
procedure, to wakeup all the processes waiting for the resource become free.
Waking them all may cause them to be simultaneously scheduled on different
processors and they would all fight for the same resource again. his is
referred to as thundering herd problem.
#5. What are the two common techni)ues used to avoid deadlock?
2ierarchial locking
%tochastic locking
#1. &xplain hierarchial locking and stochastic locking.
(n hierarchial locking, the locking mechanism imposes an order on related
locks and re)uires that all threads take locks in the same order. As long as the
ordering is strictly followed, deadlock cannot occur.
%tochastic locking is used in the situations, where the ordering should be
violated. When a process attempts to ac)uire a lock that would violate the
hierarchy, it uses try3lock<= operation instead of lock<=. his function attempts
to ac)uire the lock, but returns failure instead of blocking if the lock is already
held.
#!. What is meant by advisory processor locks?
Advisory processor locks are basically a recursive lock which contains a
hint for contending processes. he hint specifies if contending threads should
spin or sleep and whether the hint is advisory or mandatory.
##. $istinguish between parallelism and concurrency.
he parallelism of a multiprocessor application is the actual degree of
parallel execution achieved and is therefore limited by the number of physical
processors available to the application.
he application+s concurrency is the maximum parallelism it can achieve
with an unlimited number of processors and it depends on how the application
is written and how many threads of control can execute simultaneously, with
the proper resources available.
#'. $efine thread.
A thread is a dynamic ob@ect that represents a control point in the process
and that executes a se)uence of instructions. he resources such as address
space, open files, user credentials and so on are shared by all threads in the
process. (n addition, each thread has its private ob@ects such as a program
counter, a stack and a register context.
#,. "riefly explain about device drivers.
A device driver is a part of the kernel and is a collection of data structures
and functions that controls one or more devices and interacts with the rest of
the kernel through a well defined interface. (t is the only module that may
interact directly with the device. hey are extremely hardware dependent in
nature.
#-. What is meant by stream?
A stream is a full3duplex processing and data transfer path between the
kernel space and a process in user space. (t defines a framework for writing
device drivers.
#.. What is multi3processing?
(t refers to the ability of an operating system to use more than one 8P9 in
a single computer system. %ymmetrical multiprocessing refers to the :%Cs
ability to assign tasks dynamically to the next available processor, whereas
asymmetrical multiprocessing re)uires that the original program designer
choose the processor to use for a given task at the time of writing the program.
#/. What is multitasking?
;ultitasking is a logical extension of multi3programming. his refers to
the simultaneous execution of more than one program, by switching between
them, in a single computer system.
#1. What is multithreading?
;ultithreading refers to concurrent processing of several tasks or threads
inside the same program or process. 2ere, several tasks can be processed
parallely and no tasks have to wait for another to finish its execution.
'5. $efine compaction.
8ompaction refers to the mechanism of shuffling the memory portions
such that all the free portions of the memory can be aligned <or merged=
together in a single large block. 7or the :% to overcome the problem of
fragmentation, either internal or external, performs this mechanism,
fre)uently. 8ompaction is possible only if relocation is dynamic and done at
run3time, and if relocation is static and done at assembly or load3time
compaction is not possible.
'1. What do you mean by 7A <7ile Allocation able=?
(t is a table that indicates the physical location on secondary storage of the
space allocated to a file. 7A allocates clusters <group of sectors= to files. (t
chains the clusters to define the contents of the file.
'!. What is a kernel?
0ernel is the nucleus or core of the operating system. his represents small
part of the code, which is thought to be the entire operating system, it is most
intensively used. ?enerally, the kernel is maintained permanently in main
memory, and other portions of the :% are moved to and from the secondary
storage <mostly hard disk=.
'#. 2ow memory3mapped (B: works?
(n memory3mapped (B:, communication between (B: devices and the
processor is done through physical memory locations in the address space.
&ach (B: device will occupy some locations in the (B: address space. (.e., it
will respond when those addresses are placed on the bus. he processor can
write those locations to send commands and information to the (B: device and
read those locations to get information and status from the (B: device.
;emory3mapped (B: makes it easy to write device drivers in a high3level
language as long as the high3level language can load and store from arbitrary
addresses.
''. What are the advantages of threads?
hreads provide parallel processing like processes but they have one
important advantage over process, they are much more efficient.
hreads are cheaper to create and destroy because they do not re)uire
allocation and de3allocation of a new address space or other process
resources.
(t is faster to switch between threads. (t will be faster since the
memory3mapping does not have to be setup and the memory and
address translation caches do not have to be violated.
hreads are efficient as they share memory. hey do not have to use
system calls <which are slower because of context switches= to
communicate.
',. What are kernel threads?
he processes that execute in the kernel3mode that processes are called
kernel threads.
'-. What are the necessary conditions for deadlock to exist?
Mutual Exclusion: :nly one process may use a critical resource at a
time.
Hold & Wait: A process may be allocated some resources while
waiting for others.
No Pre-emption: 4o resource can be forcibly removed from a process
holding it.
Circular Wait: A closed chain of processes exist such that each process
holds at least one resource needed by another process in the chain.
hese conditions are also referred to as 8offmanCs conditions.
'.. What are the strategies for dealing with deadlock?
Prevention: Place restrictions on resource re)uests so that deadlock
cannot occur.
Avoidance: Plan ahead so that you never get in to a situation where
deadlock is inevitable.
Recovery: When deadlock is identified in the system, it recovers from
it by removing some of the causes of the deadlock.
Detection: $etecting whether the deadlock actually exists and
identifies the processes and resources that are involved in the deadlock.
'/. What is a reentrant procedure?
A reentrant procedure is the one in which multiple users can share a single
copy of a program during the same period. (t is a useful, memory3saving
techni)ue for multi3programmed timesharing systems. >eentrancy has ! key
aspectsD
he program code cannot modify itself.
he local data for each user process must be stored separately.
'1. What is a binary semaphore? What is its use?
A binary semaphore is one, which takes only 5 and 1 as values. hey are
used to implement mutual exclusion and synchroni*e concurrent processes.
,5. What is thrashing?
(t is a phenomenon in virtual memory schemes, when the processor spends
most of its time swapping pages, rather than executing instructions. his is due
to an inordinate number of page faults.
,1. What is short, long and medium3term scheduling?
Eong term scheduler determines which programs are admitted to the
system for processing. (t controls the degree of multiprogramming. :nce
admitted, a @ob becomes a process.
;edium term scheduling is part of the swapping function. his relates to
processes that are in a blocked or suspended state. hey are swapped out of
main3memory until they are ready to execute. he swapping3in decision is
based on memory3management criteria.
%hort term scheduler, also know as a dispatcher executes most fre)uently,
and makes the finest3grained decision of which process should execute next.
his scheduler is invoked whenever an event occurs. (t may lead to
interruption of one process by preemption.
,!. What are turnaround time and response time?
urnaround time is the interval between the submission of a @ob and its
completion. >esponse time is the interval between submission of a re)uest,
and the first response to that re)uest.
,#. What are the typical elements of a process image?
ser data: ;odifiable part of user space. (t may include program data,
user stack area and programs that may be modified.
ser pro!ram: he instructions to be executed.
"ystem stac#: &ach process has one or more E(7: stacks associated
with it. 9sed to store parameters and calling addresses for procedure
and system calls.
Process Control $loc# %PC$&: (nfo needed by the :% to control
processes.
,'. What is the ranslation Eookaside "uffer <E"=?
(n a cached system, the base addresses of the last few referenced pages is
maintained in registers called the E" that aids in faster lookup. E" contains
those page3table entries that have been most recently used. 4ormally, each
virtual memory reference causes ! physical memory accesses33 one to fetch
appropriate page3table entry, and one to fetch the desired data. 9sing E" in3
between, this is reduced to @ust one physical memory access in cases of E"3
hit.
,,. What is the resident set and working set of a process?
>esident set is that portion of the process image that is actually in main3
memory at a particular instant. Working set is that subset of resident set that is
actually needed for execution <>elate this to the variable3window si*e method
for swapping techni)ues=.
,-. When is a system in safe state?
he set of dispatchable processes is in a safe state, if there exists at least
one temporal order in which all processes can be run to completion without
resulting in a deadlock.
,.. What is cycle stealing?
We encounter cycle stealing in the context of $irect ;emory Access
<$;A=. &ither the $;A controller can use the data bus when the 8P9 does
not need it, or it may force the 8P9 to temporarily suspend operation. he
latter techni)ue is called cycle stealing. 4ote that cycle stealing can be done
only at specific break points in an instruction cycle.
,/. What is meant by arm3stickiness?
(f one or a few processes have a high access rate to data on one track of a
storage disk, then they may monopoli*e the device by repeated re)uests to that
track. his generally happens with most common device scheduling
algorithms <E(7:, %%7, 83%8A4, etc=. 2igh3density multi3surface disks are
more likely to be affected by this, than the low density ones.
,1. What is busy waiting?
he repeated execution of a loop of code while waiting for an event to
occur is called busy3waiting. he 8P9 is not engaged in any real productive
activity during this period, and the process does not progress toward
completion.
-5. What are local and global page replacements?
Eocal replacement means that an incoming page is brought in only to the
relevant processC address space. ?lobal replacement policy allows any page
frame from any process to be replaced. he latter is applicable to variable
partitions model only.
-1. $efine latency, transfer and seek time with respect to disk (B:.
%eek time is the time re)uired to move the disk arm to the re)uired track.
>otational delay or latency is the time to move the re)uired sector to the disk
head. %ums of seek time <if any= and the latency is the access time, for
accessing a particular track in a particular sector. ime taken to actually
transfer a span of data is transfer time.
-!. $escribe the "uddy system of memory allocation.
7ree memory is maintained in linked lists, each of e)ual si*ed blocks. Any
such block is of si*e !Fk. When some memory is re)uired by a process, the
block si*e of next higher order is chosen, and broken into two. 4ote that the
two such pieces differ in address only in their kth bit. %uch pieces are called
buddies. When any used block is freed, the :% checks to see if its buddy is
also free. (f so, it is re@oined, and put into the original free3block linked3list.
-#. 2ow are the waitBsignal operations for monitor different from those for
semaphores?
(f a process in the monitor signals and no task is waiting on the condition
variable, the signal is lost. %o this allows easier program design. Whereas in
semaphores, every operation affects the value of the semaphore, so the wait
and signal operations should be perfectly balanced in the program.
-'. (n the context of memory management, what are placement and replacement
algorithms?
Placement algorithms determine where in the available main3memory to
load the incoming process. 8ommon methods are first3fit, next3fit, and best3fit.
>eplacement algorithms are used when memory is full, and one process <or
part of a process= needs to be swapped out to accommodate the new incoming
process. he replacement algorithm determines which are the partitions
<memory portions occupied by the processes= to be swapped out.
-,. (n loading processes into memory, what is the difference between load3time
dynamic linking and run3time dynamic linking?
7or load3time dynamic linkingD Eoad module to be loaded is read into
memory. Any reference to a target external module causes that module to be
loaded and the references are updated to a relative address from the start base
address of the application module.
With run3time dynamic loadingD %ome of the linking is postponed until
actual reference during execution. hen the correct module is loaded and
linked.
--. What are demand3 and pre3paging?
With demand paging, a page is brought into the main3memory only when a
location on that page is actually referenced during execution. With prepaging,
pages other than the one demanded by a page fault are brought in. he
selection of such pages is done based on common access patterns, especially
for secondary memory devices.
-.. What is mounting?
;ounting is the mechanism by which two different file systems can be
combined together. his is one of the services provided by the operating
system, which allows the user to work with two different file systems, and
some of the secondary devices.
-/. What is process spawning?
When the :% at the explicit re)uest of another process creates a process,
this action is called process spawning.
-1. Eist out some reasons for process termination.
4ormal completion
ime limit exceeded
;emory unavailable
"ounds violation
Protection error
Arithmetic error
ime overrun
(B: failure
(nvalid instruction
Privileged instruction
$ata misuse
:perator or :% intervention
Parent termination
.5. What are the reasons for process suspension?
%wapping
(nteractive user re)uest
iming
Parent process re)uest
.1. What are the possible states a thread can have?
>eady
%tandby
>unning
Waiting
ransition
erminated
.!. $efine process.
A process is the execution of a program and consists of a pattern of bytes
that the 8P9 interprets as machine instructions, data and stack.
.#. What is called program counter?
he control point of the process tacks the se)uence of instructions using a
hardware register typically called program counter.
.'. What is known as time3slicing?
(n uni3processor system, several processes can be active in memory but
only one process can be allowed to run on the 8P9. he kernel provides an
illusion of concurrency by allowing one process to use the 8P9 for a brief
period of time called a )uantum, and then switching to another. (n this way,
each process receives some amount of 8P9 time and executes. his is known
as time slicing.
.,. What happens when a process makes system call?
When a process makes a system call, it executes a special set of
instructions to put the system in kernel mode and transfer control to the kernel,
which handles the operation on behalf of the process. After the system call is
complete, the kernel executes another set of instructions that returns back to
the user mode and transfer control back to the process.
.-. 0ernel functions may execute either in 66666666666 or in 66666666666.
Ans: process3context, system context <interrupt context=.
... What is meant by process context?
When a running process is entered into waiting state, eventually another
ready to run process should be allowed to take over the 8P9 from the running
process. (n order to rerun the already running process, the kernel must store
the context of the process, when it was about to swapped by another process.
his is meant by process context of the currently running process.
.1. he information about the system state, such as current and previous execution
modes, current and previous interrupt priority levels, overflow and carry bits
gets stored in 66666666666.
Ans: Processor %tatus Word <P%W=.
/5. $oes a process instantaneously respond to a signal? (f not, how the situation is
handled?
A process does not instantaneously respond to a signal. When the signal is
generated, the kernel notifies the process by setting a bit in the pending signals
mask. he process must become aware of the signal and respond to it, and
that can happen only when it scheduled to run. When it runs, all the pending
signals will be handled by the process before returning to its normal user3level
processing.
/1. %uppose a signal is generated for a sleeping process? %hould the signal be kept
pending or should its sleep be interrupted?
he answer depends on why the process is sleeping. (f the process is
sleeping for an event that is certain to occur soon, there is no need to wake up
the process. :n the other hand, if the process if waiting for an event, that does
not know for how long it will be waited, then the sleep should be interrupted.
/!. What are the different components of a process address space?
ext
(nitiali*ed data
9n3initiali*ed data
%hared memory
%hared libraries
2eap
9ser stack
/#. What are the main goals of memory management?
Address space management
Address translation
Physical memory management
;emory protection
;emory sharing
;onitoring system load
/'. What are the main advantages of using virtual memory?
>un programs larger than physical memory.
>educing program startup time by partially loaded programs
(ncreased 8P9 utili*ation, by allowing more than one program to
reside in memory at any time.
Allow sharing of resources.
Allow relocatable programs, which may be placed anywhere in
memory and moved around during execution.
/,. What are the main disadvantages of using virtual memory?
;emory management activities take up a significant amount of 8P9
time.
9sable memory is further reduced by fragmentation.
$ata structures used for memory management reduces the physical
memory.
Address translation is added to the execution time for each instruction.
When page fault occurs, it re)uires time3consuming disk (B:
operations by bringing the page into memory.
/-. What is called a page frame?
(n a demand3paged system, memory is divided into fixed3si*e pages and
these are brought into and out of memory as re)uired. A page of physical
memory is called a page frame.
/.. What is meant by pure demand paging?
(n pure demand paging, the pages will be brought into memory only when
needed.
//. What is meant by anticipatory paging?
(n anticipatory paging, the pages will be brought into memory, when the
system predicts that it will be needed soon.
/1. When a program gets executed, what are all the information of a program gets
stored in the pages?
ext
(nitiali*ed data
9n3initiali*ed data
;odified data
%tack
2eap
%hared memory
%hared libraries
15. What is meant by page replacement policy?
(n order to make room for a new page, the kernel must reclaim a page that
is currently in memory. he page replacement policy deals with the kernel to
decide which page to reclaim.
11. What is meant by local and global page replacement policy?
(f a process needs a new page, it must replace one of its own pages. his
is called local replacement policy.
(f a process needs a new page, it can also steal a page from any process.
his is called global replacement policy.
1!. 9nder what circumstances, the processes in the main memory should swap
out?
Any parent process wants to allocate space for its child process.
When the si*e of a process gets increased.
When returning back the already swapped3out process to memory.
1#. What is meant by disk mirroring?
$isk mirroring allows a redundant copy of all data, thus increasing the
reliability of the file system.
1'. What is meant by write3through and write3behind cache techni)ue?
A write3through cache writes out modified data blocks to the backing store
immediately, whereas in write3behind cache techni)ue, the modified blocks
are simply marked as dirty or modified, and written to the disk at a later time.
Exercises:
1. &xplain why context switch is an expensive operation.
!. What are preemptible and non3preemptible processes?
#. What are the situations that lead to context switch?
'. %tate the advantages of multiprocessor system over uniprocessor system.
,. What are the advantages and disadvantages of symmetric multiprocessing over
asymmetric multiprocessing?
-. (s it necessary that all processors in a system should be e)ual?
.. What is meant by distributed operating system and list out the advantages and
disadvantages?
/. What is meant by shared memory region and explain its advantages?
1. What is meant by synchroni*ation?
15. ?ive a situation where condition variable can be employed.
11. What are the limitations involved in process model?
1!. What is meant by $;A and $A;A?

You might also like