PROCESS MANAGEMENT
Previous GATE questions with solutions on Operating Systems (Process Concepts) – CS/IT
GATE-1996
1. The process state transition diagram in Fig.1.8 is representative of
(a) a batch operating system
(b) an operating system with a preemptive scheduler
(c) an operating system with a non-preemptive scheduler
(d) a uni-programmed operating system.
Ans: option (b)
Explanation:
If there is a transition from Running State to ready State then the state diagram is the representative of an operating system with a preemptive scheduler.
GATE-1996
3. Which of the following is an example of a spooled device?
(a) The terminal used to enter the input data for the C program being executed
(b) An output device used to print the output of a number of jobs.
(c) The secondary memory device in a virtual storage system
(d) The swapping area on a disk used by the swapper.
Ans: option (b)
GATE-1998
4. Which of the following is true?
(a) Unless enabled, a CPU will not be able to process interrupts.
(b) Loop instructions cannot be interrupted till they complete.
(c) A processor checks for interrupts before executing a new instruction.
(d) Only level triggered interrupts are possible on microprocessors
Ans: option (a)
Explanation:
Interrupts are unexpected events in a sequence of execution of instructions causing an interruption of the normal program flow.
Option (b) is false.
Option (c) depends upon the architecture of the processor.
Option (d) is false because we have level-triggered interrupts and edge-triggered interrupts.
GATE-1999
5. System calls are usually invoked by using
(a) a software interrupt (b) polling
(c) an indirect jump (d) a privileged instruction
Ans: option (a)
Explanation:
When the C library has loaded the system call index and any arguments, a software interrupt is invoked (interrupt 0x80), which results in execution (through the interrupt handler) of the system_call function. [http://www.ibm.com/developerworks/library/l-system-calls/]
GATE-1999
6. A multi-user, multi-processing operating system cannot be implemented on
hardware that does not support
(a) Address translation
(b) DMA for disk transfer
(c) At least two modes of CPU execution (privileged and non-privileged)
(d) Demand paging
Ans: options (a),(b),(c)
Explanation:
Requirements of a multi-user, multi-processing operating system are:-
1) Address translation
2) DMA for disk transfer
3) At least two modes of CPU execution (user mode and kernel mode)
GATE-1999
7. Which of the following actions is/are typically not performed by the operating
system when switching context from process A to process B?
(a) Saving current register values and restoring saved register values for process B.
(b) Changing address translation tables.
(c) Swapping out the memory image of process A to the disk.
(d) Invalidating the translation look-aside buffer.
Ans: option (c)
Explanation:
Swapping out the memory image of process to the disk occurs only when the process is suspended.
GATE-2001
9. A CPU has two modes-privileged and non-privileged. In order to change the mode
from privileged to non-privileged
(a) a hardware interrupt is needed
(b) a software interrupt is needed
(c) a privileged instruction (which does not generate an interrupt) is needed
(d) a non-privileged instruction (which does not generate an interrupt) is needed
Ans: option (c)
GATE-2001
11. Which of the following need not necessarily be saved on a context switch between processes?
(a) General purpose registers
(b) Translation look-aside buffer
(c) Program counter
(d) All of the above
Explanation:
GATE-2002
13. A process executes the code
fork ();
fork ();
fork ();
The total number of child processes created is
(a) 3 (b) 4 (c) 7 (d) 8
Explanation:
For n fork statements, 2n – 1 child processes are created.
GATE-2008
15. Consider the following code fragment:
if (fork() == 0)
{ a = a + 5; printf(“%d,%d\n”, a, &a); }
else { a = a – 5; printf(“%d,%d\n”, a, &a); }
Let u, v be the values printed by the parent process, and x, y be the values printed by the child process. Which one of the following is TRUE?
(a) u = x + 10 and v = y
(b) u = x + 10 and v != y
(c) u + 10 = x and v = y
(d) u + 10 = x and v != y
Explanation:
Child process will execute the if part and parent process will execute the else part. Assume that the initial value of a = 6. Then the value of a printed by the child process will be 11, and the value of a printed by the parent process in 1. Therefore u+10=x.Now the second part. The answer is v = y. (After compiling and verifying the above program we got the result. Explanation is given below.)We know that, the fork operation creates a separate address space for the child. But the child process has an exact copy of all the memory segments of the parent process. Hence the virtual addresses and the mapping (initially) will be the same for both parent process as well as child process. Note that, the virtual address is same but virtual addresses exist in different processes’ virtual address spaces. And when we print &a, its actually printing the virtual address. Hence the answer is v = y.The virtual address of parent & child may or may not be pointing to different physical address as explained below.
When a fork() system call is issued, a copy of all the pages corresponding to the parent process is created, loaded into a separate memory location by the OS for the child process. But this is not needed in certain cases. When the child is needed just to execute a command for the parent process, there is no need for copying the parent process’ pages, since exec replaces the address space of the process which invoked it with the command to be executed.
In such cases, a technique called copy-on-write (COW) is used. With this technique, when a fork occurs, the parent process’s pages are not copied for the child process. Instead, the pages are shared between the child and the parent process. Whenever a process (parent or child) modifies a page[To know what a page is CLICK HERE], a separate copy of that particular page alone is made for that process (parent or child) which performed the modification. This process will then use the newly copied page rather than the shared one in all future references. [Ref: WIKIPEDIA]
GATE-2009