1. Gyanastra
  2. Computer Organisation and Architecture
  3. UGC NET: Multiprocessors
  4. Interprocessor Arbitration Communication and Synchronization
Free lesson, no account needed 14 min read 23 practice questions after it
Asked in past papers3 times
  • ISRO2014
  • UGC NET20192015

Computer Organisation and Architecture · UGC NET: Multiprocessors

Interprocessor Arbitration Communication and Synchronization

Overview

In a multiprocessor system, several processors share resources such as the system bus, memory, and I/O channels.
When two or more processors request the same resource in the same cycle, hardware must decide who gets it; this is bus arbitration. Processors also need to exchange data and coordinate their actions so that shared data is not corrupted; this is interprocessor communication and synchronization. The exam tests the arbitration schemes, encoder/decoder sizes, semaphores, test-and-set spinlocks, mailboxes, message-passing models such as PVM, and basic cache-coherence behaviour.
Before studying this lesson, you should know the basic bus structure, the idea of a process and critical section, and simple binary arithmetic.

Key concepts

  • Bus arbitration is the process of selecting one requester among several contenders for a shared bus or shared resource.
  • Serial arbitration is also called daisy-chain arbitration. A common request line is asserted; the arbiter sends a grant that passes physically from device to device.
    Priority is fixed by physical position: the device nearest the arbiter has the highest priority.
  • Parallel arbitration is also called independent-request arbitration. Each device has its own request line to a central arbiter.
    The arbiter uses a priority encoder to produce the binary index of the highest-priority active request, and a decoder to activate exactly one grant line.
  • A priority encoder with 2m2^m inputs produces an mm-bit binary code for the highest-priority active input. A decoder with mm inputs produces 2m2^m one-hot outputs. For nn requesters, choose the smallest mm such that 2m≥n2^m \ge n.
  • Fixed-priority arbitration can starve a low-priority requester. Round-robin arbitration rotates priority so that every requester eventually gets a turn.
  • A semaphore is a synchronization variable. wait(S) (also called PP) and signal(S) (also called VV) must be atomic. A binary semaphore takes values 0 and 1 and is initialized to 1 for mutual exclusion.
    A counting semaphore is initialized to NN when NN identical resources are available.
  • A critical section is code that accesses shared data and must be executed by at most one process at a time. Mutual exclusion ensures this.
  • Test-and-set (TAS) is an atomic hardware instruction that reads a lock variable and sets it to 1. A spinlock repeatedly executes TAS until the lock is free; it busy-waits.
  • A monitor is a high-level synchronization construct. Its condition variables allow a process to wait without busy-waiting by being placed in a queue.
  • Interprocessor communication can be through shared memory or through message passing. A mailbox is a shared buffer for messages; a single-slot mailbox uses a full/empty flag.
  • A blocking send waits until the sender can safely reuse its buffer or until the message is accepted. A non-blocking send returns immediately.
    A blocking receive waits until a message arrives; a non-blocking receive returns immediately with a status.
  • PVM stands for Parallel Virtual Machine. It is a message-passing library that lets a heterogeneous collection of networked computers work as one parallel machine.
    Its model provides asynchronous blocking send, asynchronous blocking receive, and non-blocking receive; message buffers are allocated dynamically; any task can send to any PVM task; there is no limit on message size or number.
    In the UGC NET convention, PVM preserves message order between a given sender and receiver, so the statement “message order is not preserved” is incorrect.
  • Snooping cache coherence is used on a shared bus. Each cache monitors bus transactions. When one processor writes a block that another cache holds in shared state, the other copy is invalidated or updated before further use.
    The common write-invalidate protocol invalidates shared copies on a write.
  • A crossbar switch is a nonblocking space-division interconnection network: an N×NN \times N crossbar can connect any input to any free output at the same time because each connection uses its own crosspoint.

How it works

1. Serial daisy-chain arbitration

  1. All devices share one request line. Any device that needs the bus asserts the request line.
  2. The central arbiter asserts a single grant signal.
  3. The grant propagates through the devices in physical order. The first device in the chain that has requested the bus captures the grant and uses the bus.
  4. When that device releases the bus, the grant can propagate further to lower-priority devices.
  5. Priority is fixed by position. A faulty device that holds the grant line can block all devices after it.

2. Parallel independent-request arbitration

  1. Each requester ii has its own request line REQiREQ_i.
  2. The priority encoder receives all request lines and outputs the binary index kk of the highest-priority active request.
  3. The decoder converts the mm-bit index kk into a one-hot grant GNTkGNT_k.
  4. Requester kk gets the bus. When it releases the bus, the arbiter grants the next highest-priority active request.
  5. For nn requesters, m=⌈log⁡2n⌉m=\lceil \log_2 n \rceil. The encoder has 2m2^m inputs and mm outputs; the decoder has mm inputs and 2m2^m outputs. Unused encoder inputs are tied to 0, and unused decoder outputs are ignored.

3. Round-robin arbitration

  1. Maintain a pointer to the highest-priority requester.
  2. After granting requester ii, set the next highest priority to (i+1) mod n(i+1) \bmod n.
  3. If several requests are active, the one nearest the pointer in cyclic order wins.
  4. This prevents starvation but is slightly more complex than fixed priority.

4. Semaphore operation
Use the standard negative-value convention: wait(S) does S:=S−1S := S-1; if S<0S<0, the process blocks. signal(S) does S:=S+1S := S+1; if S≤0S\le 0, one blocked process is woken.

  1. A binary semaphore for mutual exclusion starts at S=1S=1.
  2. The first process executes wait: S=0S=0, and enters the critical section.
  3. A second process executes wait: S=−1S=-1, and blocks.
  4. On exit, the first process executes signal: S=0S=0, and wakes the blocked process.
  5. The woken process enters. The semaphore value correctly represents free resources or waiting processes.

5. Test-and-set spinlock

  1. The lock variable LL is initialized to 0.
  2. A processor executes TAS(L): it atomically returns the old value and sets L=1L=1.
  3. If the returned value is 0, the processor acquires the lock and enters the critical section.
  4. If the returned value is 1, the processor loops and retries; this is busy-waiting.
  5. On exit, the processor sets L=0L=0.
    Because TAS is atomic, two processors cannot both see the old value 0 and both enter.

6. Mailbox communication

  1. A single-slot mailbox has a message variable and a full flag.
  2. Sender: wait while full is 1; write the message; set full to 1.
  3. Receiver: wait while full is 0; read the message; set full to 0.
  4. The full/empty flag must be protected by synchronization so that both sides do not act on stale values.

7. Snooping cache coherence

  1. A processor holds a shared copy of a block.
  2. Another processor wants to write that block.
  3. The writer broadcasts an invalidation on the shared bus.
  4. Caches holding the block invalidate their copies.
  5. The writer updates its copy. A later read by another processor fetches the updated block.
Figure. Requesters have separate request lines; the priority encoder outputs the highest-priority active index, the decoder converts it into a one-hot grant, and the selected requester gets the bus.

Formulas

  • Let nn be the number of bus requesters and mm the number of bits in the requester index.

m=⌈log⁡2n⌉m = \left\lceil \log_2 n \right\rceil

  • The priority encoder size is:

2m×m2^m \times m

  • The decoder size is:

m×2mm \times 2^m

  • Round-robin next priority after granting requester ii among nn requesters:

next=(i+1) mod n\text{next} = (i+1) \bmod n

  • Semaphore convention used here:

wait(S):S:=S−1; if S<0 block\text{wait}(S): S := S-1; \text{ if } S<0 \text{ block}

signal(S):S:=S+1; if S≤0 wake one\text{signal}(S): S := S+1; \text{ if } S\le 0 \text{ wake one}

Worked examples

Example 1 (parallel arbiter sizes). A parallel bus arbiter has 5 bus requesters. Find the priority encoder and decoder sizes. Then repeat for 16 requesters.

For n=5n=5: 22=4<52^2=4<5 and 23=8≥52^3=8\ge 5, so m=3m=3. Encoder size is 23×3=8×32^3 \times 3 = 8 \times 3. Decoder size is 3×23=3×83 \times 2^3 = 3 \times 8.
For n=16n=16: 24=162^4=16, so m=4m=4. Encoder size is 16×416 \times 4, decoder size 4×164 \times 16.
Answer: 5 requesters use 8×38 \times 3 and 3×83 \times 8; 16 requesters use 16×416 \times 4 and 4×164 \times 16.

Example 2 (daisy-chain priority). Four processors P0,P1,P2,P3P_0,P_1,P_2,P_3 are in a daisy chain, with P0P_0 nearest the arbiter. P1P_1 and P3P_3 request the bus at the same time. Who gets it? What if P2P_2 is faulty and holds the grant line?

Priority order is P0>P1>P2>P3P_0>P_1>P_2>P_3. Since P1P_1 is nearer the arbiter than P3P_3, the grant stops at P1P_1. P1P_1 gets the bus. If P2P_2 holds the grant line, the grant cannot reach P3P_3, so P3P_3 is blocked.
Answer: P1P_1 gets the bus; a faulty P2P_2 can stall lower-priority P3P_3.

Example 3 (semaphore trace). A counting semaphore is initialized to S=2S=2. Processes A, B, C, D execute in order: A wait, B wait, C wait, D wait, A signal, B signal, C signal, D signal. Trace the value of SS and who enters.

Use wait: S:=S−1S:=S-1; if S<0S<0 block. Signal: S:=S+1S:=S+1; if S≤0S\le 0 wake one.
A wait: S=1S=1, A enters.
B wait: S=0S=0, B enters.
C wait: S=−1S=-1, C blocks.
D wait: S=−2S=-2, D blocks.
A signal: S=−1S=-1, wake C. C enters.
B signal: S=0S=0, wake D. D enters.
C signal: S=1S=1, no wake.
D signal: S=2S=2.
Answer: Final S=2S=2; A, B, C, D all eventually enter in the order A, B, then C, then D after wakes.

Example 4 (test-and-set). Lock L=0L=0. Processors X and Y both try TAS(L) at the same time. Explain the outcome.

TAS is atomic: it returns the old value and sets L=1L=1. One processor, say X, receives old value 0 and sets L=1L=1; X enters. Y receives old value 1 and sets L=1L=1; Y spins. When X finishes, X sets L=0L=0. Y’s next TAS returns 0, sets L=1L=1, and Y enters.
Answer: Exactly one enters first; the other busy-waits until the lock is released.

Example 5 (statement type). Statement I: In a parallel arbiter, the priority encoder output can be fed to a decoder to produce a one-hot grant. Statement II: A binary semaphore used for mutual exclusion should be initialized to 0.

Statement I is true: encoder gives the selected index, decoder converts it to one grant line. Statement II is false: a binary semaphore for mutual exclusion is initialized to 1 so that the first wait succeeds. If it were initialized to 0, the first process would block.
Answer: I true, II false.

Comparison

FeatureDaisy-chain arbitrationParallel arbitrationRound-robin arbitration
PriorityFixed by physical positionFixed by request-line priority unless rotatedRotating, fair
WiringFew grant/request linesSeparate request lines, more wiresSimilar to parallel plus pointer logic
SpeedSlow because grant propagatesFast, encoder/decoder delayFast but extra rotation logic
Fault sensitivityA faulty device can block downstream devicesFault on one request line is localFault on one request line is local
StarvationHigh-priority devices favouredLow-priority devices may starveNo starvation
FeatureBinary semaphoreCounting semaphore
Values0 or 10 to NN
Initial value for mutual exclusion1Not used for simple mutual exclusion
MeaningLock free or heldNumber of available resources
Typical useCritical sectionResource pool of NN units
FeatureBlocking sendNon-blocking send
Sender behaviourWaits until safe to proceedReturns immediately
Buffer pressureControlledSender must later check completion
Typical useSimple reliable handoffOverlap communication with computation
FeatureSpinlock with TASSemaphore or monitor
WaitingBusy-waitsBlocks in queue
CPU useWastes cycles while waitingFrees CPU
Good forVery short critical sections on multiprocessorGeneral synchronization
UniprocessorPoor, since spinner wastes the only CPUBetter

Revision summary

  • m=⌈log⁡2n⌉m=\lceil \log_2 n\rceil; encoder 2m×m2^m\times m, decoder m×2mm\times 2^m.
  • 5 requesters give 8×38\times3 encoder and 3×83\times8 decoder.
  • Daisy chain: priority by physical position; nearest arbiter is highest.
  • A faulty device holding the grant line blocks all lower-priority devices.
  • Parallel fixed priority can starve low-priority requesters; round-robin is fair.
  • Binary semaphore for mutual exclusion starts at 1; counting semaphore starts at NN.
  • wait decrements and blocks if negative; signal increments and wakes if non-positive.
  • TAS is atomic; spinlock busy-waits; bad on a uniprocessor for long waits.
  • PVM = Parallel Virtual Machine;
    dynamic buffers, any-to-any, no size limit, order preserved in the exam convention.
  • Blocking send waits; non-blocking send returns immediately.
  • Single-slot mailbox uses a full flag; sender waits if full, receiver waits if empty.
  • Snooping write-invalidate: a write invalidates shared copies in other caches.

Previous-year exam insights

  • PVM questions are usually statement-type.
    Check every property: send/receive types, dynamic buffers, any-to-any communication, size limit, and message ordering.
    The statement “order is not preserved” is the wrong option in the UGC NET convention.
  • Parallel arbitration numericals ask for encoder/decoder sizes.
    First compute m=⌈log⁡2n⌉m=\lceil\log_2 n\rceil, then use 2m×m2^m\times m and m×2mm\times 2^m.
    Do not use exactly n×mn\times m when nn is not a power of two.
  • Daisy-chain questions test priority by position and fault behaviour.
    The grant propagates; a device that holds it blocks downstream requesters.
  • Semaphore questions test initial values and traces.
    Binary semaphore for mutual exclusion is initialized to 1; counting semaphore initialized to 3 means three resources are free.
  • Test-and-set questions test atomicity.
    If two processors execute TAS together, exactly one sees old value 0; the other spins.
  • Match-the-list items pair daisy chain with position priority, parallel arbitration with encoder/decoder, mailbox with message buffer, and semaphore with resource count or mutual exclusion.
  • Round-robin numericals use rotating priority: after granting ii, the next priority starts at i+1i+1 modulo nn.
  • Snooping-coherence questions ask what happens to a shared copy when another processor writes.
    The shared copy is invalidated or updated according to the protocol; write-invalidate is the usual answer.
  • Trap: directly feeding a priority encoder output to a decoder can assert grant 0 when no request is active.
    A valid/any-request signal must enable the decoder.

Practice at PARIKSHA

You are ready for the PARIKSHA tests of this sub-topic when you can:

  1. Compute encoder and decoder sizes for 5, 8, 16, and 32 bus requesters.
  2. Explain why a daisy-chain arbiter gives priority by physical position and how a faulty device blocks lower-priority devices.
  3. Trace a parallel arbiter when two or more request lines are active and state which grant line is asserted.
  4. Trace a binary semaphore through several wait/signal calls and state which processes enter or block.
  5. Trace a counting semaphore initialized to NN and state the meaning of the value at each step.
  6. Explain the atomic test-and-set loop and why two processors cannot enter a critical section together.
  7. Distinguish blocking send, non-blocking send, blocking receive, and non-blocking receive with one example each.
  8. List the PVM properties and identify which statement is incorrect in a statement-type question.
  9. Explain how a single-slot mailbox uses a full flag and when the sender or receiver waits.
  10. State what happens to a shared cache copy when another processor writes the block under snooping write-invalidate.

Attempt the sub-topic test first, then the subject test.

Pages 1–2 of 2