OPERATING SYSTEM MCQ 9


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

2. Which of the following is an example of spooled device?
(a) A line printer used to print the output of a number of jobs.
(b) A terminal used to enter input data to a running program.
(c) A secondary storage device in a virtual memory sytem.
(d) A graphic display device.
 
Ans: option (a)
Explanation:
Spool stands for simultaneous peripheral operations on-line.
The most common spooling application is print spooling: Printers typically can print only a single document at a time and require seconds or minutes to do so. With spooling, multiple processes can write documents to a print queue without waiting. As soon as a process has written its document to the spool device, the process can perform other tasks, while a separate printing process operates the printer.
Reference: http://en.wikipedia.org/wiki/Spooling

GATE-1998
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

8. A processor needs software interrupt to
(a) test the interrupt system of the processor
(b) implement co-routines
(c) obtain system services which need execution of privileged instructions
(d) return from subroutine
 
Ans: option (c)

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

10. Which of the following does not interrupt a running process?
(a) A device                   (b) Timer
(c) Scheduler process      (d) Power failure
 
Ans: option (c)
Explanation:
Scheduler process is to determine which process next should run in the CPU. It does not interrupt any running process.

GATE-2000
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
Ans: option (b)
Explanation:

A Translation lookaside buffer (TLB) is a CPU cache that memory management hardware uses to improve virtual address translation speed. On a context switch, some TLB entries can become invalid, since the virtual-to-physical mapping is different. The simplest strategy to deal with this is to completely flush the TLB.

GATE-2002

12. Which combination of the following features will suffice to characterize an OS as a multi-programmed OS?
(A) More than one program may  be loaded into main memory at the same time for execution.
(B) If a program waits for certain events such as I/O, another program is immediately scheduled for execution.
(C) If the execution of a program terminates, another program is immediately scheduled for execution.
(a) A                    (b) A and B                (c) A and C              (d) A, B and C
 
Ans: option (a)
Explanation:
Ability of the operating system to manage and hold multiple programs in the memory is known as multi-programmed OS.

GATE-2012
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
Ans: option (c)
Explanation:
For n fork statements,  2n – 1 child processes are created.


GATE-2008

14. A process executes the following code
   for (i = 0; i < n; i++) fork();
The total number of child processes created is
(a) n
(b) 2n – 1
(c) 2n
(d) 2n+1 – 1;
 
Ans: option (b)
Explanation:
Loop executes for n times. Therefore, fork() is executed for n times.
For n fork statements,  2n – 1 child processes are created.

GATE-2005
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
Ans: option (c)
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

16. In the following process state transition diagram for a uniprocessor system,
assume that there are always some processes in the ready state:
 
Now consider the following statements:
I. If a process makes a transition D, it would result in another process making transition A immediately.
II. A process P2 in blocked state can make transition E while another process P1 is in running state.
III. The OS uses preemptive scheduling.
IV. The OS uses non-preemptive scheduling.
Which of the above statements are TRUE?
(a) I and II           (b) I and III           (c) II and III          (d) II and IV
 
Ans: option (c)
Explanation:
If a process makes a transition D, it would result in another process making transition from ready state to running state .i.e. transition B.
A process moves to ready state when I/O or other events are completed.
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.

Leave a comment