QB Module II New
QB Module II New
While switching between each process we must save the PCB details of process being taken
out and similarly when we must load a new process the PCB details of that process have to be
loaded. These activities consume time and so is considered as overhead while switching
between processes.
3. How many times will forked get printed in the below program. Justify your answer. [June
2022]
Int main ()
{
Fork ();
Fork ();
Printf (“forked \n”);
Return (0);
}
Forked will get printed three times. First it will be printed for the main program. Next two
times it will be printed for two fork functions.
4. List and explain various synchronous and asynchronous methods of message passing in IPC.
[June 2022]
Communication between processes takes place through calls to send () and receive ()
primitives. Message passing may be either blocking or nonblocking also known as
synchronous and asynchronous.
In synchronous mode send and receive operation takes place as follows
Blocking send - The sending process is blocked until the message is received by the receiving
process or by the mailbox.
Blocking receive - The receiver blocks until a message is available.
In asynchronous mode send and receive operation takes place as follows
Non-blocking send - The sending process sends the message and resumes operation.
Nonblocking receive - The receiver retrieves either a valid message or a null.
5. Explain the different buffering mechanism used in message passing system. [June 2023]
Whether communication is direct or indirect, messages exchanged by communicating
processes reside in a temporary queue. Such queues can be implemented in three ways:
Zero capacity. The queue has a maximum length of zero; thus, the link cannot have any
messages waiting in it. In this case, the sender must block until the recipient receives the
message.
Bounded capacity. The queue has finite length n; thus, at most n messages can reside in it. If
the queue is not full when a new message is sent, the message is placed in the queue (either
the message is copied or a pointer to the message is kept), and the sender can continue
execution without waiting. The link’s capacity is finite, however. If the link is full, the sender
must block until space is available in the queue.
Unbounded capacity. The queue’s length is potentially infinite; thus, any number of messages
can wait in it. The sender never blocks.
PART B
6. Explain how long-term scheduler directly affects system performance. [July 2021] [5 MARKS]
Long term scheduler selects jobs from job pool and assigns them to ready queue for execution
by CPU. A long-term scheduler’s primary function is to minimize processing time by taking the
mixtures of CPU-bound jobs and I/O-bound jobs.
CPU Bound Jobs: CPU-bound jobs are tasks or processes that necessitate a significant amount
of CPU processing time and resources (Central Processing Unit). These jobs can put a
significant strain on the CPU, affecting system performance and responsiveness.
I/O Bound Jobs: I/O bound jobs are tasks or processes that necessitate many input/output
(I/O) operations, such as reading and writing to discs or networks. These jobs are less
dependent on the CPU and can put a greater strain on the system’s I/O subsystem.
So, the long -term scheduler picks a correct mixture of CPU bound and I/O bound jobs to
maintain a good system performance.
7. A writer process needs to send a bulk of information to reader process. Explain the IPC
mechanism that can be used for this purpose. [July 2021] [8 MARKS]
For sending a bulk of information shared memory concept of IPC can be used. Inter process
communication using shared memory requires communicating processes to establish a region
of shared memory. A shared-memory region resides in the address space of the process
creating the shared-memory segment. Other processes that wish to communicate using this
shared-memory segment must attach it to their address space. They can then exchange
information by reading and writing data in the shared areas. The processes are also
responsible for ensuring that they are not writing to the same location simultaneously.
8. How many child process will be created for following code. [July 2021] [6 MARKS]
Void main ()
{
Fork ();
Fork ();
Printf (“HELLO\n”);
Fork ();
Printf (“WELCOME\n”);
}
How many times HELLO and WELCOME will be printed?
Seven child process will be created for the above code. Hello will be printed 4 times and
Welcome will be printed 8 times.
9. Five batch process A to E arrive in the system in the order A to E at the same time. They have
running times of 6, 4, 1, 3, 7 and have priorities 3, 5, 2, 1, 4 with 5 being highest priority.
Calculate the average waiting time using [July 2021] [12 MARKS]
a. RR Time quantum = 2
b. FCFS
c. SJF
d. Priority
FCFS
The queue has a maximum length of zero; thus, the link cannot have any messages waiting in
it. In this case, the sender must block until the recipient receives the message.
11. What is meant by context switching? Illustrate the context switching with a diagram. [June
2022] [6 MARKS]
Switching between various processes is called as context switching. Whenever a process must
service an interrupt or I/O it is removed from execution and another process is selected for
execution. When a process is removed its status must be saved so that it can resume the
operation from the point it left. The PCB of process is saved and PCB of another one is loaded
that is ready for execution.
12. Differentiate between the following [June 2022] [8 MARKS]
15. With an example, illustrate the inter process communication using Shared memory. [June
2022] [7 MARKS]
16. What are threads? What are the benefits of multithreaded programming? List the
ways of establishing relationship between user threads and kernel threads. [June
2022] [6 MARKS]
Many-to-One
Many user-level threads mapped to single kernel thread
One-to-One
Each user-level thread maps to kernel thread
Examples
Windows NT/XP/2000
Linux
Many-to-Many
Allows many user level threads to be mapped to many kernel threads
Allows the operating system to create enough kernel threads
Example
Windows NT/2000
17. Assume you have the following jobs in a system that to be executed with a
single processor. Now,