Q24
Which of the following statements about threads is/are TRUE?
More than one option can be correct.
Show answer without attempting
Answer: D
GATE CS · 126 questions
126 Operating Systems questions from GATE CS papers, each with the official answer key. Answer any question right here and it is marked straight away, or practise them one at a time.
Answer: D
Answer: B, C
Answer: A
fork() and wait() system calls. Assume that the code compiles and runs correctly, and that the system calls run successfully without any errors.int x = 3;
while(x > 0) {
fork();
printf("hello");
wait(NULL);
x--;
}printf statement is executed is _______Answer: 14
Answer: 6596
Answer: B, C, D
Answer: A, B
Answer: B
// code of T1
wait(s1);
x = x+1;
print(x);
wait(s2);
signal(s1);
// code of T2
wait(s1);
x = x+1;
print(x);
signal(s2);
signal(s1);Answer: B, C
Answer: 1028
Answer: B, C, D
Answer: C, D
Answer: A, C, D OR C, D
incr and decr shown below.incr(){
wait(s);
X = X+1;
signal(s);
}
decr(){
wait(s);
X = X-1;
signal(s);
}incr once, and 3 threads each invoking decr once, on the same shared variable X. The initial value of X is 10.s, as follows:s is a binary semaphore initialized to 1.s is a counting semaphore initialized to 2.X at the end of execution of all the threads with implementations I-1, I-2, respectively.Answer: C
D in the C programming language, which is stored in row-major order:int D[128][128];D. The Least Recently Used (LRU) page-replacement policy is used by the operating system. A total of 30 physical page frames are allocated to a process which executes the following code snippet:for (int i = 0; i < 128; i++)
for (int j = 0; j < 128; j++)
D[j][i] *= 10;Answer: 4096
Answer: 5
T1
while(true){
wait(S3);
print(“C”);
signal(S2);
}
T2
while(true){
wait(S1);
print(“B”);
signal(S3);
}
T3
while(true){
wait(S2);
print(“A”);
signal(S1);
}Answer: C
Answer: A, D
Answer: C
Answer: D
0/200 correct0 marks