Machine-translated by Google. Questions are authored in English.
Top

Processes and Threads Questions and Answers

1.

A ______ is the subset of a process and is also known as the lightweight process.

Exam Year(s)

DSSSB TGT - 2023,

Answer: A

A thread is a subset of a process and is called a lightweight process. Several threads of one process share its memory and resources while each has its own stack and registers, so creating or switching them costs less than doing so for whole processes. A program is a passive set of instructions, a library is a collection of reusable routines, and a process is the larger unit that holds the threads. Because threads of one process share the same memory, switching between them is faster than switching between processes, which is why they are called lightweight.

Please log in or register to report this question.

2.

Match the column Functions with the column descriptions.

FunctionsDescriptions
a) Multiprocessingi) Two or more users can work with programs and share peripheral devices, such as printers, at the same time.
b) Multithreadingii) The computer can have two or more central processing units (CPUs) that programs share.
c) Multiuseriii) A program can be broken into smaller parts that can be loaded as needed by the operating system.

Exam Year(s)

DSSSB TGT - 2023,

Answer: A

The correct match is a-ii, b-iii, c-i. Multiprocessing means the computer has two or more CPUs that programs share (ii). Multithreading means a program is broken into smaller parts that the operating system loads as needed (iii), as the table in the question puts it. Multiuser means two or more users can work with programs and share peripheral devices such as printers at the same time (i). In each wrong option at least one of these three pairs is changed.

Please log in or register to report this question.

Answer: D

The true statement is Threads belonging to a process are by default not protected from each other.

Threads of one process share its address space, open files and other resources. Any thread can read or overwrite memory used by another, so the operating system provides no protection between them; protection exists between processes.

The other statements are false. Threads can be implemented in user space by a thread library as well as in the kernel. The file descriptor table belongs to the process and is shared by all its threads. Each thread has its own stack, along with its own registers and program counter, because each runs its own sequence of function calls.

Please log in or register to report this question.

4.

Let P and Q be the two processes which are interlinked and by an indirect mode of communication. Which of the following mechanisms they will adopt ?

Exam Year(s)

MH SET - 2018, SET Exam - 2018,

Answer: B

They will use a mailbox to communicate.

In indirect communication, messages are not sent to a named process but to a mailbox (also called a port), an object into which messages can be placed and from which they can be removed. P sends to the mailbox and Q receives from it; the two processes communicate only if they share the mailbox.

A relaying process R or a separate machine is not what defines indirect communication in the operating systems sense, so those options, and 'All of the above', are wrong.

Please log in or register to report this question.

5.

On termination which of the following system call does not return control to calling point :

Exam Year(s)

MH SET - 2018, SET Exam - 2018,

Answer: A

The call that does not return to the calling point is exec.

A successful exec replaces the calling process's program with a new one: the old code, data and stack are discarded, so there is nothing to return to and execution begins at the new program's entry point. exec returns only if it fails.

fork returns twice, once in the parent (with the child's process ID) and once in the child (with 0), and ioctl returns a status to its caller. longjmp is a library function, not a system call, and it jumps back to a point saved earlier by setjmp.

Please log in or register to report this question.

6.

The process state transition diagram for a UNIX like uniprocessor system is given below :

ArrowFromTo
AKernel RunningUser Running
BUser RunningKernel Running
CSleeping StateKernel Running
DKernel RunningSleeping State
EReady to RunKernel Running
FKernel RunningReady to Run
GSleeping StateReady to Run
HReady to RunSleeping State

Which transitions are not possible ?

Exam Year(s)

MH SET - 2018, SET Exam - 2018,

Answer: B

The impossible transitions are C, H, F.

In the simplified UNIX process state diagram (as in Bach's account of the UNIX kernel), a process moves between user running and kernel running on system calls, interrupts and returns (A, B); a running process in kernel mode goes to sleep when it must wait for an event (D); a sleeping process is woken into the ready state (G); and the scheduler picks a ready process to run in kernel mode (E).

A sleeping process cannot go straight to running (C); it must first become ready. A ready process cannot go to sleep (H), since only a running process can sleep. And in this diagram a process in kernel mode does not move directly to ready (F). Options A, C and D all include possible transitions such as A, D, G or E.

Please log in or register to report this question.

7.

Which system call replaces a current process in Linux ?

Exam Year(s)

MH SET - 2023, SET Exam - 2023,

Answer: C

The system call is exec.

The exec family (execve and its wrappers such as execl and execvp) replaces the current process image with a new program: the code, data and stack are replaced, while the process ID stays the same. It does not return on success.

fork creates a new child process that is a copy of the caller, rather than replacing it; the usual pattern is fork followed by exec in the child. pipe creates a channel between processes, and dup duplicates a file descriptor.

Please log in or register to report this question.

8.

Consider a system with 'M' CPU processors and 'N' processes then how many processes can be present in ready, running and blocked state at maximum ?

Exam Year(s)

MH SET - 2025, SET Exam - 2025,

Answer: A

The maxima are N, M, N for ready, running and blocked.

At most one process can run on each processor, so no more than M processes can be running at once (assuming N is at least M). Any process can be waiting for a CPU, so up to all N can be in the ready state at an instant, and any process can be waiting for an event, so up to all N can be blocked.

Options giving M as the maximum for ready or blocked are too small, since those states are not tied to the number of processors. N running is impossible with only M CPUs, and N+M exceeds the number of processes.

Please log in or register to report this question.

Answer: C

The false statement is that the kernel stack is used to store the user program's function arguments.

Arguments, return addresses and local variables of a user program's function calls are kept on the user stack.

The kernel stack is used while the process executes in kernel mode, for system calls and interrupt handling, and it holds the saved context (registers) of the process at that time. That saved context, which the paper prints as 'Content of the process', is what allows the process to be restarted later. So the other three statements are true.

Please log in or register to report this question.

10.

The number of child processes are created using the following code :

int main()
{ fork(););
  fork();
  fork();
  return 0;
}

Exam Year(s)

MH SET - 2025, SET Exam - 2025,

Answer: C

The code creates 7 child processes.

Each fork() duplicates every process that executes it, so the number of processes doubles with each call. After three calls there are

\[ \begin{aligned} 2^{3} &= 8 \text{ processes} \\ &= 1 \text{ parent} + 7 \text{ children} \end{aligned} \]

The first line as printed has a stray ');' after the first call, which a compiler would reject; the question intends three successive fork() calls. 8 counts the original parent as well, and 5 and 6 do not arise from doubling.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Processes and Threads Questions and Answers || Processes and Threads MCQ Questions and Answers || Processes and Threads GK Questions and Answers || Processes and Threads GK MCQ Questions || Processes and Threads Multiple Choice Questions and Answers || Processes and Threads GK || GK on Processes and Threads || Operating Systems Questions and Answers || Operating Systems MCQ Questions and Answers || Operating Systems GK Questions and Answers || GK on Operating Systems