UNIT II Two Marks
UNIT II Two Marks
PART–A
Q.1 Define process. What is the information maintained in a PCB ?
Ans. A process is simply a program in execution. i.e. an instance of a program.
execution. PCB maintains pointer, state, process number, CPU register, PC,
memory allocation etc.
Q.2 Define task control block.
Ans. TCB is also called PCB.
Q.3 What is PCB? Specify the information maintained in it. AU CSE/IT:
Dec.-12
Ans. Each process is represented in the operating system by a process control
block. PCB contains information like process state, program counter, CPU register,
accounting information etc.
Q.4 What is independent process ?
Ans. Independent process cannot affect or be affected by the execution of another
process.
Q.5 Name and draw five different process states with proper definition. AU:
Dec.-17
Ans. Process states are new, running, waiting, ready and terminated. Fig. 2.16.1
shows process state diagram.
Q.21 Define the term What is the concept behind strong semaphore and
spinlock?.
Time it takes for the dispatcher to stop one process and start another running.
Q.22 What is preemptive priority method?
Ans. A preemptive priority will preempt the CPU if the newly arrived process is
higher than the priority of the currently running process.
Q.23 What is medium term scheduling ?
Ans. Medium-term scheduling used especially with time-sharing systems as an
intermediate scheduling level. A swapping scheme is implemented to remove
partially run programs from memory and reinstate them later to continue where
they left off.
Q.24 What is preemptive scheduling ?
Ans. Preemptive scheduling can preempt a process which is utilizing the CPU in
between its execution and give the CPU to another process.
Q.25 What is the difference between long-term scheduling and short-term
scheduling ?
Ans. Long term scheduling adds jobs to the ready queue from the job queue. Short
term scheduling dispatches jobs from the ready queue to the running state.
Q.26 List out any four scheduling criteria.
Ans. Response time, throughput, waiting time and turn around time.
Q.27 Define the term 'Dispatch latency'.
Ans. Dispatch latency: Time it takes for the dispatcher to stop one process and start
another running. It is the amount of time required for the scheduler to stop one
process and start another.
Q.28 Distinguish between CPU-bounded and I/O bounded processes.
Ans.
Q.29 Define priority inversion problem.
Ans. The higher priority process would be waiting for the low priority one to
finish. This situation is known as priority inversion problem.
Q.30 What advantage is there in having different time-quantum sizes on
different levels of a multilevel queuing system?
Ans.Processes that need more frequent servicing, for instance, interactive
processes such as editors, can be in a queue with a small time quantum. Processes
switch no need for frequent servicing can be in a queue with a larger quantum,
requiring fewer context switches to complete the processing, and thus making
more efficient use of the computer.
Q.31 How does real-time scheduling differs from normal scheduling ?
Ans. Normal scheduling provides no guarantee on when a critical process will be
scheduled; it guarantees only that the process will be given preference over non-
critical processes. Real-time systems have stricter requirements. A task must be
serviced by its deadline; service after the deadline has expired is the same as no
service at all.
Q.32 What is Shortest-Remaining-Time-First (SRTF) ?
Ans. If a new process arrives with CPU burst length less than remaining time of
process, current executing preempt. This scheme is known as the
Shortest-Remaining-Time-First.
Q.33 What is round robin CPU scheduling ?
Ans. Each process gets a small unit of CPU time (time quantum). After this time
has elapsed, the process is preempted and added to the end of the ready queue.
Q.34 What is meant by starvation in operating system?
Ans. Starvation is a resource management problem where a process does not get
the resources (CPU) it needs for a long time because the resources are being
allocated to other processes.
Q.35 What is an aging?
Ans. Aging is a technique to avoid starvation in a scheduling system. It works by
adding an aging factor to the priority of each request. The aging factor must
increase the requests priority as time passes and must ensure that a request will
eventually be the highest priority request
Q.36 How to solve starvation problem in priority CPU scheduling ?
Ans. Aging - as time progresses increase the priority of the process, so eventually
the process will become the highest priority and will gain the CPU. i.e., the more
time is spending a process in ready queue waiting, its priority becomes higher and
higher.
Q.37 What is convoy effect?
Ans. A convoy effect happens when a set of processes need to use a resource for a
short time, and one process holds the resource for a long time, blocking all of the
other processes. Essentially it causes poor utilization of the other resources in the
system.
Q.38 How can starvation / indefinite blocking of processes be avoided in
priority scheduling ?
Ans. A solution to the problem of indefinite blockage of processes is aging. Aging
is a technique of gradually increasing the priority of processes that wait in the
system for a long time.
Q.39"Priority inversion is a condition that occurs in real time systems where a
low priority process is starved because higher priority processes have gained
hold of the CPU" - Comment on this statement. AU CSE: May-17
Ans. A low priority thread always starts on a shadow version of the shared
resource, the original resource remains unchanged. When a high-priority thread
needs a resource engaged by a low -priority thread, the low priority thread is
preempted, the original resource is restored and the high priority thread is allowed
to use the original
Q.40 Provide two programming examples in which multithreading provides
better. performance than a single-threaded solution.
Ans. A Web server that services each request in a separate thread.
A parallelized application such as matrix multiplication where different parts of the
matrix may be worked on in parallel.
An interactive GUI program such as a debugger where a thread is used to monitor
user input, another thread represents the running application, and a show third
thread monitors performance.
Q.41 State what does a thread share with peer threads.
Ans. Thread share the memory and resource of the process.
Q.42 Define a thread. State the major advantage of threads.
Ans. A thread is a flow of execution through the process's code with its own
program counter, system registers and stack.
2. Efficient communication.
Advantages: 1. Minimize context switching time.
Q.43 Can a multithreaded solution using multiple user-level threads achieve
better performance on a multiprocessor system than on a single processor
system ?
Ans. A multithreaded system comprising of multiple user-level threads cannot
make use of the different processors in a multiprocessor system simultaneously.
The operating system sees only a single process and will not schedule the different
threads of the process on separate processors. Consequently, there is no
performance benefit associated with executing multiple user-level threads on a
multiprocessor system.
Q.44 What are the differences between user-level threads and kernel-level
threads ? (Refer section 2.8.3)
Ans:
CPU bound process, spends majority of its time simply using the CPU (doing
calculations). I/O bound process, spends majority of its time in input/output related
operations.
Ans: When a thread is Creatingd the threads does not require any new resources to
execute. The thread shares the resources of the process to which it belongs to and it
requires a small data structure to hold a register set, stack, and priority.
Ans: A thread otherwise called a lightweight process (LWP) is a basic unit of CPU
utilization, it comprises of a thread id, a program counter, a register set and a stack.
It shares with other threads belonging to the same process its code section, data
section, and operating system resources such as open files and signals.
Ans: The benefits of multithreaded programming can be broken down into four
major categories:
• Responsiveness
• Resource sharing
• Economy
Ans: The thread cancellation is the task of terminating a thread before it has
completed. A thread that is to be cancelled is often referred to as the target thread.
For example, if multiple threads are concurrently searching through a database and
one thread returns the result, the remaining threads might be cancelled.
87. What are the different ways in which a thread can be cancelled?
88. What are the various scheduling criteria for CPU scheduling?
• CPU utilization
• Throughput
• Turnaround time
• Waiting time
• Response time
89. What are the requirements that a solution to the critical section problem must
satisfy?
• Mutual exclusion
• Progress
• Bounded waiting
Ans: Consider a system consists of 'n' processes.Each process has segment of code
called a critical section, in which the process may be changing common variables,
updating a table, writing a file.When one process is executing in its critical section,
no other process can allowed executing in its critical section.
Ans: Turnaround time is the interval from the time of submission to the time of
completion of a process. It is the sum of the periods spent waiting to get into
memory, waiting in the ready queue, executing on the CPU, and doing I/O.
92. Name two hardware instructions and their definitions which can be used for
implementing
mutual exclusion.
Ans:
• TestAndSet
boolean rv = target;
target = true;
return rv;
• Swap
a = b;
b = temp;
Ans:
94.
DEADLOCK
Q.1 What is a deadlock ?
Ans. A set of processes is deadlocked if each process in the set is waiting for an
event that only another process in the set can cause. Usually the event is release of
a currently held resource.
Q.2 State the conditions for deadlock.
Four conditions for deadlocks are:
Ans. :
a. Mutual exclusion
b. Hold and wait
c. No preemption
d. Circular wait
1. Atleast one resource must be held in a nonsharable mode.
2. A process holding atleast one resource is waiting for more resources held by
other processes.
3.Resources cannot be preempted.
4.There must be a circular waiting.
Q.3 What is deadlock state ?
Ans. If there is any process deadlock in a state, then that state is called deadlock
state.
Q.4 What is resource-allocation graph ?
Ans. Deadlocks can be described more precisely in terms of a directed graph called
a system resource-allocation graph.
Q.5 Is it possible to have a deadlock involving only one process? State your
answer.
Ans. No. This follows directly from the hold-and-wait condition.
Q.6 List two examples of deadlocks that are not related to a computer system
environment.
Ans. a. Two cars crossing a single-lane bridge from opposite directions.
b. A person going down a ladder while another person is climbing up the ladder:
Q7. Define safe state.
Ans. A state is safe if the system can allocate resources to each process (up to its
maximum) in some order and still avoid a deadlock.
Q.8 When is a set of processes deadlocked ?
Ans. Resource deadlock : Each process requests resources held by another process
in the set and it must receive all the requested resources before it can become
unblocked. Communication deadlock: Each process is waiting for communication
from another process and will not communicate until it receives the
communication for which it is waiting.
Q.9 Define request edge and assignment edge.
Ans. There is a request edge from process P to resource R if and only if P is
blocked waiting for an allocation of R. There is an assignment edge from resource
R to process P if and only if P is holding an allocation of R.
Q.10 What is hold and wait?
Ans. Hold and Wait : A process must be holding a resource and waiting for
another.
Q.11 What is a knot ?
Ans. A strongly connected sub-graph of a directed graph, such that starting from
any node in the subset it is impossible to leave the knot by following the edges of
the graph.
Q.12 What is banker's algorithm ?
Ans. Banker's algorithm is a deadlock avoidance algorithm that is applicable to a
resource-allocation system with multiple instances of each resource type.
Q.13 Which are two options to break a deadlock ?
Ans. There are two options for breaking a deadlock :
1. Process termination: To abort one or more processes to break the circular wait.
2. Resource preemption: To preempt some resources from one or more of deadlock
Q.14 Write the three ways to deal the deadlock program.
Ans. Three ways to deal with the deadlock problem :
1. Use a protocol to prevent or avoid deadlocks, ensuring that the system will never
enter a deadlock state.
2. Allow the system to enter a deadlock state, detect it and recover.
3. Ignore the problem altogether and pretend that deadlocks never occur in the
system.
Q.15 List out the methods used to recover from the deadlock.
Ans. Recovery from Deadlock methods are process termination, resource
preemption. In process termination, all deadlocked processes are abort or abort one
process at a time until the deadlock cycle is eliminated. Resource preemption
procedure is selecting a victim, rollback and starvation.
16. Define Starvation in deadlock?
Ans: A problem related to deadlock is indefinite blocking or starvation, a situation
where processes wait indefinitely within a semaphore. Indefinite blocking may
occur if we add and remove processes from the list associated with a semaphore in
LIFO order.