Operating System - Weekly Test 04 - Test Paper
Operating System - Weekly Test 04 - Test Paper
[MCQ]
5. Consider the following code:
Which of the following is correct about above RAG? Process P0 code: Process P1 code:
(a) Both (i) and (ii) has Deadlock while(true) while(true)
(b) Only (i) has Deadlock { {
(c) Only (ii) has Deadlock non-CS(); non-CS();
(d) None of (i) and (ii) has Deadlock. while(true!=0); while(true!=1);
[CS] [CS]
[NAT] true = 1; true = 0;
3. Consider an operating system containing ‘n’ processes } }
each requiring 5 resources. The maximum number of Initially CS value was true = 0. Which of the condition
processes that can be executed without any deadlock if this code is not satisfying?
there are 20 resources is _____. (a) Mutual Exclusion
(b) Progress
(c) Bounded waiting
[NAT]
(d) All of these.
4. Consider three concurrent processes, P1, P2, and P3, as
shown below, which access a shared variable X that
has been initialized to 100.
2
[MSQ]
[MCQ]
6. Consider a system with 3 types of resources R1, R2 and
8. Consider the following code:
R3 in quantity 5, 7, 5 respectively. The allocation and
main ()
max matrices are given as follows:
int a = 0;
Allocation
int b = 0;
R1 R2 R3
begin
P1 2 1 0
Parbegin
P2 1 2 1
thread P();
P3 0 2 2
thread Q();
P4 1 1 1
Parend;
end;
Max
R1 R2 R3
thread P(); threadQ();
2 3 3 begin begin
2 3 2 a = 1; /*statement 1*/ b = 4; /*statement 3*/
3 2 3 b = b + a; /*statement2*/ a = a + 5; /*statement 4*/
3 3 2 end; end;
Which of the following safe sequences are possible?
(a) P4 P2 P1 P3 Suppose a process has 2 concurrent threads; one thread
(b) P2 P4 P3 P1
executes statement 1 and 2 and other thread executes
(c) P2 P1 P4 P3
statement 3 and 4. What are the possible values of
(d) P2 P4 P1 P3
variable ‘a’ and ‘b’ when the code finishes execution?
(a) a = {1, 5, 6}
b = {10, 4, 5}
[MCQ]
(b) a = {1, 5, 6}
7. Consider X, Y, Z are shared semaphore on following
b = {1, 4, 5}
three concurrent processes:
(c) a = {1, 6}
b = {10, 4, 5}
Process-1 Process-2 Process-3
(d) a = {1, 6}
P(X) P(Y) P(Z)
b = {1, 4, 5}
P(Z) Print “B” P(X)
Print “A” Print “E” Print “C”
Print “D” V(X) Print “F” [MCQ]
V(Y) V(Z) 9. Consider program for P1 and P2:
If these processes run concurrently and possible P1() P2()
outputs are CFBEAD, ADCFBE, ACFDBE. What
{ {
could be the initial value of X, Y and Z. So that above
outputs are possible? P(m); P(n)
(a) X = 2, Y = 0, Z = 1 x++; y++;
(b) X = 2, Y = 0, Z = 2 P(n); P(m);
(c) X = 1, Y = 0, Z = 2
(d) X = 2, Y = 0, Z = 1 y++; x++;
V(n); V(m);
V(m); V(n);
} }
3
[MCQ]
10. Consider the following code:
begin
S1 ;
Parbegin
(c)
S2;
S3;
begin S4; S5; end
Parend;
S6 ;
(d) None of these.
Which of the following is correct precedence graph for
the above code?
(a)
4
Answer Key
1. (40) 6. (b, d)
2. (d) 7. (b)
3. (4) 8. (c)
4. (180) 9. (d)
5. (b) 10. (b)
5
9. (d)
P1()
1. P(m) therefore, option (b) is correct.
2. x ++
For more questions, kindly visit the library section: Link for web: https://smart.link/sdfez8ejd80if