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 inputs produces an -bit binary code for the highest-priority active input. A decoder with inputs produces one-hot outputs. For requesters, choose the smallest such that .
- 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 ) and signal(S) (also called ) 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 when 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 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
- All devices share one request line. Any device that needs the bus asserts the request line.
- The central arbiter asserts a single grant signal.
- 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.
- When that device releases the bus, the grant can propagate further to lower-priority devices.
- Priority is fixed by position. A faulty device that holds the grant line can block all devices after it.
2. Parallel independent-request arbitration
- Each requester has its own request line .
- The priority encoder receives all request lines and outputs the binary index of the highest-priority active request.
- The decoder converts the -bit index into a one-hot grant .
- Requester gets the bus. When it releases the bus, the arbiter grants the next highest-priority active request.
- For requesters, . The encoder has inputs and outputs; the decoder has inputs and outputs. Unused encoder inputs are tied to 0, and unused decoder outputs are ignored.
3. Round-robin arbitration
- Maintain a pointer to the highest-priority requester.
- After granting requester , set the next highest priority to .
- If several requests are active, the one nearest the pointer in cyclic order wins.
- This prevents starvation but is slightly more complex than fixed priority.
4. Semaphore operation
Use the standard negative-value convention: wait(S) does ; if , the process blocks. signal(S) does ; if , one blocked process is woken.
- A binary semaphore for mutual exclusion starts at .
- The first process executes wait: , and enters the critical section.
- A second process executes wait: , and blocks.
- On exit, the first process executes signal: , and wakes the blocked process.
- The woken process enters. The semaphore value correctly represents free resources or waiting processes.
5. Test-and-set spinlock
- The lock variable is initialized to 0.
- A processor executes TAS(L): it atomically returns the old value and sets .
- If the returned value is 0, the processor acquires the lock and enters the critical section.
- If the returned value is 1, the processor loops and retries; this is busy-waiting.
- On exit, the processor sets .
Because TAS is atomic, two processors cannot both see the old value 0 and both enter.
6. Mailbox communication
- A single-slot mailbox has a message variable and a full flag.
- Sender: wait while full is 1; write the message; set full to 1.
- Receiver: wait while full is 0; read the message; set full to 0.
- The full/empty flag must be protected by synchronization so that both sides do not act on stale values.
7. Snooping cache coherence
- A processor holds a shared copy of a block.
- Another processor wants to write that block.
- The writer broadcasts an invalidation on the shared bus.
- Caches holding the block invalidate their copies.
- The writer updates its copy. A later read by another processor fetches the updated block.
Drawing the diagram…
Formulas
- Let be the number of bus requesters and the number of bits in the requester index.
- The priority encoder size is:
- The decoder size is:
- Round-robin next priority after granting requester among requesters:
- Semaphore convention used here:
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 : and , so . Encoder size is . Decoder size is .
For : , so . Encoder size is , decoder size .
Answer: 5 requesters use and ; 16 requesters use and .
Example 2 (daisy-chain priority). Four processors are in a daisy chain, with nearest the arbiter. and request the bus at the same time. Who gets it? What if is faulty and holds the grant line?
Priority order is . Since is nearer the arbiter than , the grant stops at . gets the bus. If holds the grant line, the grant cannot reach , so is blocked.
Answer: gets the bus; a faulty can stall lower-priority .
Example 3 (semaphore trace). A counting semaphore is initialized to . 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 and who enters.
Use wait: ; if block. Signal: ; if wake one.
A wait: , A enters.
B wait: , B enters.
C wait: , C blocks.
D wait: , D blocks.
A signal: , wake C. C enters.
B signal: , wake D. D enters.
C signal: , no wake.
D signal: .
Answer: Final ; A, B, C, D all eventually enter in the order A, B, then C, then D after wakes.
Example 4 (test-and-set). Lock . 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 . One processor, say X, receives old value 0 and sets ; X enters. Y receives old value 1 and sets ; Y spins. When X finishes, X sets . Y’s next TAS returns 0, sets , 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
| Feature | Daisy-chain arbitration | Parallel arbitration | Round-robin arbitration |
|---|---|---|---|
| Priority | Fixed by physical position | Fixed by request-line priority unless rotated | Rotating, fair |
| Wiring | Few grant/request lines | Separate request lines, more wires | Similar to parallel plus pointer logic |
| Speed | Slow because grant propagates | Fast, encoder/decoder delay | Fast but extra rotation logic |
| Fault sensitivity | A faulty device can block downstream devices | Fault on one request line is local | Fault on one request line is local |
| Starvation | High-priority devices favoured | Low-priority devices may starve | No starvation |
| Feature | Binary semaphore | Counting semaphore |
|---|---|---|
| Values | 0 or 1 | 0 to |
| Initial value for mutual exclusion | 1 | Not used for simple mutual exclusion |
| Meaning | Lock free or held | Number of available resources |
| Typical use | Critical section | Resource pool of units |
| Feature | Blocking send | Non-blocking send |
|---|---|---|
| Sender behaviour | Waits until safe to proceed | Returns immediately |
| Buffer pressure | Controlled | Sender must later check completion |
| Typical use | Simple reliable handoff | Overlap communication with computation |
| Feature | Spinlock with TAS | Semaphore or monitor |
|---|---|---|
| Waiting | Busy-waits | Blocks in queue |
| CPU use | Wastes cycles while waiting | Frees CPU |
| Good for | Very short critical sections on multiprocessor | General synchronization |
| Uniprocessor | Poor, since spinner wastes the only CPU | Better |
Revision summary
- ; encoder , decoder .
- 5 requesters give encoder and 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 .
- 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 , then use and .
Do not use exactly when 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 , the next priority starts at modulo .
- 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:
- Compute encoder and decoder sizes for 5, 8, 16, and 32 bus requesters.
- Explain why a daisy-chain arbiter gives priority by physical position and how a faulty device blocks lower-priority devices.
- Trace a parallel arbiter when two or more request lines are active and state which grant line is asserted.
- Trace a binary semaphore through several wait/signal calls and state which processes enter or block.
- Trace a counting semaphore initialized to and state the meaning of the value at each step.
- Explain the atomic test-and-set loop and why two processors cannot enter a critical section together.
- Distinguish blocking send, non-blocking send, blocking receive, and non-blocking receive with one example each.
- List the PVM properties and identify which statement is incorrect in a statement-type question.
- Explain how a single-slot mailbox uses a full flag and when the sender or receiver waits.
- 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.