GATE-CS-2006

Last Updated :
Discuss
Comments

Question 1

Barrier is a synchronization construct where a set of processes synchronizes globally i.e. each process in the set arrives at the barrier and waits for all others to arrive and then all processes leave the barrier. Let the number of processes in the set be three and S be a binary semaphore with the usual P and V functions. Consider the following C implementation of a barrier with line numbers shown on left.

C
void barrier (void) {
1:   P(S);
2:   process_arrived++;
3.   V(S);
4:   while (process_arrived !=3);
5:   P(S);
6:   process_left++;
7:   if (process_left==3) {
8:      process_arrived = 0;
9:      process_left = 0;
10:  }
11:  V(S);
} 

The variables process_arrived and process_left are shared among all processes and are initialized to zero. In a concurrent program all the three processes call the barrier function when they need to synchronize globally. Which one of the following rectifies the problem in the implementation?

  • Lines 6 to 10 are simply replaced by process_arrived--

  • At the beginning of the barrier the first process to enter the barrier waits until process_arrived becomes zero before proceeding to execute P(S).

  • Context switch is disabled at the beginning of the barrier and re-enabled at the end.

  • The variable process_left is made private instead of shared

Question 2

Barrier is a synchronization construct where a set of processes synchronizes globally i.e. each process in the set arrives at the barrier and waits for all others to arrive and then all processes leave the barrier. Let the number of processes in the set be three and S be a binary semaphore with the usual P and V functions. Consider the following C implementation of a barrier with line numbers shown on left.

C
void barrier (void) {
1:   P(S);
2:   process_arrived++;
3.   V(S);
4:   while (process_arrived !=3);
5:   P(S);
6:   process_left++;
7:   if (process_left==3) {
8:      process_arrived = 0;
9:      process_left = 0;
10:  }
11:  V(S);
} 

The variables process_arrived and process_left are shared among all processes and are initialized to zero. In a concurrent program all the three processes call the barrier function when they need to synchronize globally. The above implementation of barrier is incorrect. Which one of the following is true?

  • The barrier implementation is wrong due to the use of binary semaphore S

  • The barrier implementation may lead to a deadlock if two barrier in invocations are used in immediate succession.

  • Lines 6 to 10 need not be inside a critical section

  • The barrier implementation is correct if there are only two processes instead of three.

Question 3

The atomic fetch-and-set x, y instruction unconditionally sets the memory location x to 1 and fetches the old value of x n y without allowing any intervening access to the memory location x. consider the following implementation of P and V functions on a binary semaphore S.

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?

  • The implementation may not work if context switching is disabled in P

  • Instead of using fetch-and –set, a pair of normal load/store can be used

  • The implementation of V is wrong

  • The code does not implement a binary semaphore

Question 4

Consider the data given in

above question

. Consider the correct spanning tree for the previous question. Let host H1 send out a broadcast ping packet. Which of the following options represents the correct forwarding table on B3?[2 marks] (A)

 Hosts Port
 H1, H2, H3, H4 3
 H5, H6, H9, H10 1
 H7, H8, H11, H12 2

(B)

 Hosts Port
 H1, H2 4
 H3, H4 3
 H5, H6 1
 H7, H8, H9, H10,H11,H12 2

(C)

 Hosts Port
H3, H4 3
H5, H6, H9, H10 1
 H1, H2 4
 H7, H8, H11, H12 2

(D)

 Hosts Port
 H1, H2, H3, H4 3
 H5, H7, H9, H10 1
 H7, H8, H11, H12 4
  • A

  • B

  • C

  • D

Question 5

Consider the diagram shown below where a number of LANs are connected by (transparent) bridges. In order to avoid packets looping through circuits in the graph, the bridges organize themselves in a spanning tree. First, the root bridge is identified as the bridge with the least serial number. Next, the root sends out (one or more) data units to enable the setting up of the spanning tree of shortest paths from the root bridge to each bridge.
Each bridge identifies a port (the root port) through which it will forward frames to the root bridge. Port conflicts are always resolved in favour of the port with the lower index value. When there is a possibility of multiple bridges forwarding to the same LAN (but not through the root port), ties are broken as follows: bridges closest to the root get preference and between such bridges, the one with the lowest serial number is preferred.

cs200682


For the given connection of LANs by bridges, which one of the following choices represents the depth first traversal of the spanning tree of bridges?

  • B1, B5, B3, B4, B2

  • B1, B3, B5, B2, B4

  • B1, B5, B2, B3, B4

  • B1, B3, B4, B5, B2

Question 6

Station A uses 32 byte packets to transmit messages to Station B using a sliding window protocol. The round trip delay between A and B is 80 milliseconds and the bottleneck bandwidth on the path between A and B is 128 kbps. What is the optimal window size that A should use?

  • 20

  • 40

  • 160

  • 320

Question 7

Consider the following C-program fragment in which i, j and n are integer variables.

C
for (i = n, j = 0; i >0; i /= 2, j += i);

Let val(j) denote the value stored in the variable j after termination of the for loop. Which one of the following is true?

(A) val(j) = Θ(logn)

(B) vaI(j) = Θ(sqrt(n))

(C) val(j) =Θ (n)

(D) val(j) = Θ(nlogn)

  • A

  • B

  • C

  • D

Question 8

A computer system supports 32-bit virtual addresses as well as 32-bit physical addresses. Since the virtual address space is of the same size as the physical address space, the operating system designers decide to get rid of the virtual memory entirely. Which one of the following is true?

  • Efficient implementation of multi-user support is no longer possible

  • The processor cache organization can be made more efficient now

  • Hardware support for memory management is no longer needed

  • CPU scheduling can be made more efficient now

Question 9

A CPU generates 32-bit virtual addresses. The page size is 4 KB. The processor has a translation look-aside buffer (TLB) which can hold a total of 128 page table entries and is 4-way set associative. The minimum size of the TLB tag is:

  • 11 bits

  • 13 bits

  • 15 bits

  • 20 bits

Question 10

Let SHAM3 be the problem of finding a Hamiltonian cycle in a graph G = (V,E) with V divisible by 3 and DHAM3 be the problem of determining if a Hamiltonian cycle exists in such graphs. Which one of the following is true?

  • Both DHAM3 and SHAM3 are NP-hard

  • SHAM3 is NP-hard, but DHAM3 is not

  • DHAM3 is NP-hard, but SHAM3 is not

  • Neither DHAM3 nor SHAM3 is NP-hard

Tags:

There are 84 questions to complete.

Take a part in the ongoing discussion