ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Computer Architecture
    COMP3147
    Progress0 / 24 topics
    Topics
    1. Digital Hardware Design: Transistors and Digital logic2. Hardware description languages (Verilog)3. Instruction Set Architecture: Instruction types and mixes4. Addressing modes5. RISC vs. CISC architectures6. Exceptions in instruction sets7. Scalar Pipelines: Data dependencies8. Static scheduling9. Pipeline performance analysis10. VLIW Pipelines: Local scheduling11. Loop unrolling and Software pipelining12. Trace scheduling13. Deferred exceptions and Predicated execution14. IA64 architecture15. Dynamic Pipelines: Dynamical scheduling16. Register renaming17. Speculative execution18. Trace cache19. Thread-Level Parallelism: Cache coherency20. Sequential consistency21. Multithreading22. Symmetric multiprocessing23. Transactional memory24. Data-Level Parallelism: GPU programming
    COMP3147›Multithreading
    Computer ArchitectureTopic 21 of 24

    Multithreading

    3 minread
    443words
    Beginnerlevel

    ⭐ Multithreading (MT)

    1. Definition

    Multithreading is a processor technique that allows a single CPU or core to execute multiple threads concurrently, improving CPU utilization and throughput.

    A thread is the smallest unit of execution within a program, with its own program counter, registers, and stack, but sharing the process’s memory.


    2. Purpose

    1. Hide long-latency operations: e.g., memory access or I/O waits.
    2. Improve CPU utilization: When one thread stalls, another can execute.
    3. Increase throughput: Multiple threads progress in parallel.

    3. Types of Multithreading

    A) Fine-Grained Multithreading

    • Switches between threads every CPU cycle.
    • Advantage: Hides latency effectively.
    • Disadvantage: Single thread executes slower, as CPU is shared every cycle.

    B) Coarse-Grained Multithreading

    • Switches threads only on long-latency events (e.g., cache misses).
    • Advantage: Less context-switching overhead.
    • Disadvantage: CPU may be idle if no thread stalls.

    C) Simultaneous Multithreading (SMT)

    • Multiple threads issue instructions in the same cycle using the same pipeline.
    • Example: Intel Hyper-Threading Technology.
    • Advantage: Maximizes resource utilization in superscalar pipelines.

    4. How Multithreading Works

    1. Each thread has its own program counter and registers.
    2. Threads share execution units, caches, and memory.
    3. CPU switches between threads rapidly (fine-grained) or on stalls (coarse-grained).
    4. In SMT, instructions from multiple threads can be issued simultaneously to different functional units.

    5. Benefits of Multithreading

    1. Better CPU utilization: Keeps pipelines busy when one thread stalls.
    2. Higher throughput: More instructions executed per unit time.
    3. Reduced branch and memory stall penalties: Another thread can execute during a stall.
    4. Cost-effective: Multiple threads share a single core, unlike multi-core designs.

    6. Challenges / Limitations

    1. Resource contention: Threads compete for functional units, caches, or memory bandwidth.
    2. Complex scheduling: Requires hardware or OS support to switch threads efficiently.
    3. Security risks: Shared caches and resources can lead to side-channel attacks (e.g., Spectre, Meltdown).
    4. Not all workloads benefit: Single-thread heavy workloads may not see improvement.

    7. Relation to Other Concepts

    Concept Relation to Multithreading
    Thread-Level Parallelism (TLP) Multithreading is a key technique to achieve TLP.
    Cache Coherency Important when threads share data in multicore systems.
    Speculative Execution Can work together with multithreading to improve pipeline utilization.
    Superscalar Pipelines SMT allows multiple threads to issue instructions simultaneously in a superscalar core.

    8. Example

    Assume two threads, T1 and T2:

    Cycle Pipeline Stage
    1 T1 fetch
    2 T2 fetch, T1 decode
    3 T1 execute, T2 decode
    4 T2 execute
    • Fine-grained: Switch threads every cycle → hides stalls.
    • Coarse-grained: Switch thread only when one stalls → less frequent context switching.

    9. Exam-Friendly Summary

    • Multithreading: Concurrent execution of multiple threads on a single CPU/core.
    • Types: Fine-grained, Coarse-grained, Simultaneous (SMT).
    • Goal: Improve CPU utilization, hide stalls, increase throughput.
    • Limitations: Resource contention, complexity, limited benefit for single-threaded workloads.
    Previous topic 20
    Sequential consistency
    Next topic 22
    Symmetric multiprocessing

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time3 min
      Word count443
      Code examples0
      DifficultyBeginner