Understanding Control, Data, and Structural Hazards in Computer Architecture Quiz

Explore fundamental concepts of control, data, and structural hazards in pipelined processors with this quiz. Enhance your comprehension of hazard types, pipeline behavior, and common solutions in computer architecture.

  1. Definition of Control Hazards

    Which type of hazard occurs when the pipeline makes incorrect predictions regarding the next instruction to execute, such as after a branch instruction?

    1. Data hazard
    2. Control hazard
    3. Resource hazard
    4. Structural hazard

    Explanation: A control hazard arises when the flow of instructions is altered, typically by branches and jumps, leading to uncertainty in the pipeline. Data hazards involve dependencies between data in instructions. Structural hazards are due to hardware resource conflicts. Resource hazard is a less precise term and generally refers to structural hazards.

  2. Structural Hazard Example

    If two instructions in the pipeline need access to the same memory unit at the same time, what type of hazard does this situation create?

    1. Data hazard
    2. Structural hazard
    3. Control hazard
    4. Timing hazard

    Explanation: A structural hazard occurs when hardware resources are inadequate for simultaneous operations. Control hazards are related to instruction flow changes. Timing hazard is not a commonly used term in this context. Data hazards refer to conflicts with data dependencies, not resource usage.

  3. Data Hazard Identification

    What kind of hazard happens when an instruction depends on the result of a previous instruction that has not yet completed, such as reading a register before it’s updated?

    1. Structural hazard
    2. Control hazard
    3. Instruction hazard
    4. Data hazard

    Explanation: Data hazards involve dependencies where one instruction requires data that is yet to be produced by another. Control hazards are about instruction sequence changes. Instruction hazard is not a specific standard type. Structural hazards are due to hardware resource conflicts, not data dependencies.

  4. Resolving Data Hazards

    Which technique reduces data hazards by forwarding data from later pipeline stages to earlier ones, as seen in operations like add followed by another add?

    1. Stalling
    2. Branch prediction
    3. Data forwarding
    4. Resource duplication

    Explanation: Data forwarding (bypassing) provides results directly to the dependent instruction, minimizing pipeline delays. Stalling pauses the pipeline but is less efficient. Branch prediction addresses control hazards, not data dependencies. Resource duplication targets structural hazards.

  5. Stalling as a Solution

    When the pipeline temporarily stops processing new instructions to resolve a data dependency, what is this method called?

    1. Pipelining
    2. Decoding
    3. Branching
    4. Stalling

    Explanation: Stalling introduces delays by halting instruction processing until dependencies are resolved. Pipelining is the method of instruction overlap, not specifically a hazard solution. Branching refers to conditional jumps in program flow. Decoding is the instruction interpretation step, not a hazard resolution technique.

  6. Branch Prediction and Hazards

    Which hazard can be mitigated using techniques like 'branch prediction' to improve pipeline efficiency?

    1. Structure hazard
    2. Path hazard
    3. Control hazard
    4. Data hazard

    Explanation: Branch prediction aims to guess the outcome of branch instructions, reducing idle pipeline cycles due to control hazards. Data hazards are resolved using forwarding or stalls. 'Structure hazard' is a typo for structural hazard, but branch prediction does not address structural hazards. 'Path hazard' is not a standard term in this context.

  7. Impact of Structural Hazards

    If a pipelined processor has only one unified memory for instructions and data, what hazard might this cause when fetching and loading simultaneously?

    1. Structural hazard
    2. Logic hazard
    3. Control hazard
    4. Data hazard

    Explanation: A single memory unit becomes a resource bottleneck, causing a structural hazard when simultaneous instruction and data access are required. Data hazards relate to information dependencies. Logic hazard is not a recognized standard in this context. Control hazards pertain to branch instructions, not resources.

  8. True Dependency

    When one instruction needs a value produced by a previous instruction, as in 'ADD R1, R2, R3' followed by 'SUB R4, R1, R5', what is the hazard type involved?

    1. Redundant hazard
    2. Order hazard
    3. Structure hazard
    4. Data hazard

    Explanation: The dependency occurs because the second instruction relies on the register updated by the first, which defines a data hazard. 'Order hazard' and 'redundant hazard' are not standard types. 'Structure hazard' concerns resource contention, not data dependencies.

  9. Hazard-Free Pipeline

    Which condition prevents structural hazards in a pipeline architecture?

    1. Overlapping instruction fetch with execution
    2. Guessing the branch outcome randomly
    3. Stalling the pipeline for every instruction
    4. Providing enough hardware resources for all simultaneous operations

    Explanation: Ensuring adequate resources prevents resource conflicts, thus avoiding structural hazards. Stalling is a response to certain hazards, not a way to prevent structural hazards. Random branch prediction is related to control hazards. Overlapping fetch with execution is standard in pipelining and does not specifically prevent hazards.

  10. Pipeline Bubble Purpose

    What is the main function of inserting a 'bubble' (NOP) in a pipeline when a hazard is detected?

    1. To eliminate the need for branch prediction
    2. To allow simultaneous resource access by conflicting instructions
    3. To delay later instructions and prevent incorrect execution
    4. To speed up instruction execution rate

    Explanation: A bubble or NOP halts pipeline advancement, ensuring hazards don't lead to incorrect results. It does not speed up execution, but introduces a delay. Bubbles do not replace branch prediction as they mainly address data and control hazards. They don't solve simultaneous resource access issues, which require hardware solutions.