OA. free
Free
Texas Instruments Embedded Systems & Hardware Embedded Systems & Hardware Medium

6.

Texas Instruments technical mcq question, verified with a worked answer. Free to practise - no sign-up.

Identify dependency between instructions

You come across two instructions i and j where j tries to write to a register before i reads that register.

In the given context, what type of dependency exists between i and j?

Note: The original ordering must be preserved to ensure that i reads the correct value.

Choose one option.
Show answer & explanation
Answer: B. B) Anti-dependence

An anti-dependence (Write-After-Read or WAR) occurs when a later instruction (j) writes to a register that an earlier instruction (i) must read first. If the order is reversed, instruction i would read the updated value instead of the original value, leading to incorrect program execution.

Step-by-step Derivation:
Step 1: Analyze the sequence of operations. Instruction i reads register R, and instruction j writes to register R.
Step 2: Identify the temporal order. Instruction i occurs before instruction j (i < j).
Step 3: Define the dependency type based on the access pattern: Read(i) followed by Write(j) to the same location.
Step 4: Compare with standard data dependency definitions:

  • True Dependency (RAW): Write(i) followed by Read(j). Not this case.
  • Anti-Dependence (WAR): Read(i) followed by Write(j). This matches the scenario.
  • Output Dependence (WAW): Write(i) followed by Write(j). Not this case.
    Step 5: Conclusion: Since j tries to write to a register before i reads it (violating the original program order), this is a Write-After-Read (WAR) conflict, known as an anti-dependence.