Operating systems miscellaneous
- A process executes the following code for (i = 0 ; i < n; i ++) for ();
The total number of child processes created is
-
View Hint View Answer Discuss in Forum
We know that the total number of processes is 2n but we subtract the main process therefore, total number of children = 2(n – 1) .
Correct Option: B
We know that the total number of processes is 2n but we subtract the main process therefore, total number of children = 2(n – 1) .
- 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:
1. If a process makes a transition D, it would result in another process making transition A immediately.
2. A process P2 is blocked state can make transition E while another process P1 is in running state.
3. The operating system uses pre-emptive scheduling.
4. The operating system uses non-pre-emptive scheduling. Which of the above statements are true?
-
View Hint View Answer Discuss in Forum
1. is false. If a process makes a transition D, it would result in another process making transition B, not A. 2. is true. A process can move to ready state when I/O completes irrespective of other process being in running state or not.
3. is true because there is a transition from running to ready state.
4. is false as the OS uses preemptive schedulingCorrect Option: C
1. is false. If a process makes a transition D, it would result in another process making transition B, not A. 2. is true. A process can move to ready state when I/O completes irrespective of other process being in running state or not.
3. is true because there is a transition from running to ready state.
4. is false as the OS uses preemptive scheduling
- A multithreaded program P executes with x number of threads and uses y number of locks for ensuring mutual exclusion while operating on shared memory locations. All locks in the program are non-reentrant, i.e, if a thread holds a lock l, then it cannot re-acquire lock l without releasing it. If a thread is unable to acquire a lock, it blocks until the lock becomes available. The minimum value of x and the minimum value of y together for which execution of P can result in a deadlock are :
-
View Hint View Answer Discuss in Forum
In an multithreaded program P executes with X number of threads and Y number of locks for ensuring mutual exclustion while operating on shared memory location. Now consider each option.
(a) X = 1, Y = 2.
If there is one thread and two locks then there is not situation of deadlock.
(b) X = 2, Y = 1.
Similarly if there is only 1 lock and 2 thread, then there will be no deadlock situation.
(c) X = 2, Y = 2
If there is 2 thread and 2 locks then the Deadlock situation can arise because both threads can holds one lock and can wait for release of another lock, which arises deadlock.
(d) X = 1, Y = 1
If there is one thread and one locks, then one thread can hold one lock, then there will be no deadlock situation.
So, option (c) is correct.Correct Option: C
In an multithreaded program P executes with X number of threads and Y number of locks for ensuring mutual exclustion while operating on shared memory location. Now consider each option.
(a) X = 1, Y = 2.
If there is one thread and two locks then there is not situation of deadlock.
(b) X = 2, Y = 1.
Similarly if there is only 1 lock and 2 thread, then there will be no deadlock situation.
(c) X = 2, Y = 2
If there is 2 thread and 2 locks then the Deadlock situation can arise because both threads can holds one lock and can wait for release of another lock, which arises deadlock.
(d) X = 1, Y = 1
If there is one thread and one locks, then one thread can hold one lock, then there will be no deadlock situation.
So, option (c) is correct.
- Which of the following is/are shared by all the threads in a process?
I. Program counter
II. Stack
III. Address space
IV. Registers
-
View Hint View Answer Discuss in Forum
The thread is a light weight process and all the threads in a process has share address space but other entities like, stack, PC, registers are not shared and every thread will have its own.
So, option (b) is correct.Correct Option: B
The thread is a light weight process and all the threads in a process has share address space but other entities like, stack, PC, registers are not shared and every thread will have its own.
So, option (b) is correct.
- The maximum number of processes that can be in Ready state for a computer system with n CPUs is
-
View Hint View Answer Discuss in Forum
Number of processes which are in running processes will be atmost n as there are n processors. Maximum number of processes that will be in ready state is independent of number of processors.
Correct Option: D
Number of processes which are in running processes will be atmost n as there are n processors. Maximum number of processes that will be in ready state is independent of number of processors.