ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalCOMP3147Multithreading
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    COMP3147

    Computer Architecture

    Progress0 / 24 done
    Topics24
    1Transistors and Digital logic2Hardware description languages (Verilog)
    3Instruction types and mixes4Addressing modes5RISC vs. CISC architectures6Exceptions in instruction sets
    7Data dependencies8Static scheduling9Pipeline performance analysis
    10Local scheduling11Loop unrolling and Software pipelining12Trace scheduling13Deferred exceptions and Predicated execution14IA64 architecture
    15Dynamical scheduling16Register renaming17Speculative execution18Trace cache
    19Cache coherency20Sequential consistency21Multithreading22Symmetric multiprocessing23Transactional memory
    24GPU programming
    3 min read
    Topic 21 of 24
    Topic Study Note Illustration
    21

    Multithreading

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

    ⭐ 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 view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    3mremaining
    443words
    Beginnerlevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Computer Architecture