Question 1
if (fork() == 0)
{ a = a + 5; printf(\"%d,%d\\n\", a, &a); }
else { a = a –5; printf(\"%d, %d\\n\", a, &a); }
Question 2
void P (binary_semaphore *s) { unsigned y; unsigned *x = &(s->value); do { fetch-and-set x, y; } while (y); } void V (binary_semaphore *s) { S->value = 0; }Which one of the following is true?
Question 3
Question 4
Question 5
Process X: Process Y: private i; private i; for (i=0; i < n; i++) { for (i=0; i < n; i++) { a[i] = f(i); EntryY(R, S); ExitX(R, S); b[i]=g(a[i]); } }Which one of the following represents the CORRECT implementations of ExitX and EntryY? (A)
ExitX(R, S) { P(R); V(S); } EntryY (R, S) { P(S); V(R); }(B)
ExitX(R, S) { V(R); V(S); } EntryY(R, S) { P(R); P(S); }(C)
ExitX(R, S) { P(S); V(R); } EntryY(R, S) { V(S); P(R); }(D)
ExitX(R, S) { V(R); P(S); } EntryY(R, S) { V(S); P(R); }
Question 6
Question 7
A shared variable x, initialized to zero, is operated on by four concurrent processes W, X, Y, Z as follows. Each of the processes W and X reads x from memory, increments by one, stores it to memory, and then terminates. Each of the processes Y and Z reads x from memory, decrements by two, stores it to memory, and then terminates. Each process before reading x invokes the P operation (i.e., wait) on a counting semaphore S and invokes the V operation (i.e., signal) on the semaphore S after storing x to memory. Semaphore S is initialized to two. What is the maximum possible value of x after all processes complete execution?
Question 8
Process X: Process Y: private i; private i; for (i=0; i < n; i++) { for (i=0; i < n; i++) { a[i] = f(i); EntryY(R, S); ExitX(R, S); b[i]=g(a[i]); } }Which one of the following represents the CORRECT implementations of ExitX and EntryY? (A)
ExitX(R, S) { P(R); V(S); } EntryY (R, S) { P(S); V(R); }(B)
ExitX(R, S) { V(R); V(S); } EntryY(R, S) { P(R); P(S); }(C)
ExitX(R, S) { P(S); V(R); } EntryY(R, S) { V(S); P(R); }(D)
ExitX(R, S) { V(R); P(S); } EntryY(R, S) { V(S); P(R); }
Question 9
fork(); fork(); fork();The total number of child processes created is
Question 10
AcquireLock(L){ while (Fetch_And_Add(L,1)) L = 1; } ReleaseLock(L){ L = 0; }This implementation
There are 115 questions to complete.