Part C

Cards (146)

  • Thread : One process, but more than one point of execution, multiple program counters
  • Threads share address space (code, data), one page table .
  • Each thread has own state, PC and registers, scheduled, context switch, own stack (thread-local storage), thread control block (TCB)
  • Thread Control Block (TCB) contains:
    TID
    Thread State
    PC and Registers
    Stack
  • Parallelization : A single-threaded program to multiple threads, each on one CPU.
  • Most modern applications are multithreaded
  • Threads run within application
  • Multiple tasks with the application can be implemented by separate threads :
    Update display, Fetch data, Spell checking, Answer a network request
  • Multiple processes vs a process with multiple threads :
    Process creation is heavy-weight while thread creation is light-weight Can simplify code, increase efficiency
  • Kernels are generally multithreaded
  • This is an example of Multithreaded Server Architecture :
  • Parallelism implies a system can perform more than one task simultaneously
  • Concurrency supports more than one task making progress
  • Types of Parallelism:
    Data Parallelism
    Task Parallelism
  • Data parallelism – distributes subsets of the same data across multiple cores, same operation on each
  • Task parallelism – distributing threads across cores, each thread performing unique operation
  • This is an example of Data Parallelism :
  • This is an example of Task Parallelism :
  • Benefits of Parallelism:
    Responsiveness
    Resource Sharing
    Economy
    Scalability
  • User threads - management done by user-level threads library
  • Three primary thread libraries:
    POSIX Pthreads
    Windows threads
    Java threads
  • Kernel threads - Supported by the Kernel
  • virtually all general purpose operating systems, including Windows, Linux, Mac OS X, iOS, Android are all examples of kernel threads
  • Multithreading Models:
    Many to One
    One to One
    Many to Many
  • Many to One :
    Many user-level threads mapped to single kernel thread
    One thread blocking causes all to block Multiple threads may not run in parallel on multicore system because only one may be in kernel at a time
  • This is an example of a Many to One Thread Model:
  • Solaris Green Threads and GNU Portable Threads are examples of a Many to One thread model.
  • One to One :
    Each user-level thread maps to the kernel thread
    Creating a user-level thread creates a kernel thread
    More concurrency than many-to-one
    The number of threads per process is sometimes restricted due to overhead
  • Windows and Linux are examples of One to One thread models
  • This is an example of a One to One thread model:
  • Many to Many :
    Allows many user level threads to be mapped to many kernel threads Allows the operating system to create a sufficient number of kernel threads
  • This is an example of a Many to Many thread model :
  • Two level model : Similar to M:M, except that it allows a user thread to be bound to kernel thread
  • This is an example of a Two Level thread model :
  • Thread library provides programmer with API for creating and managing threads
  • Two primary ways of implementing thread libraries :
    Library entirely in user space
    Kernel-level library supported by the OS
  • Pthreads may be provided either as user-level or kernel-level
  • Multiple threads within a process _ .
    1. Will always execute the same sequence of instructions
    2. Must execute within disjoint parts of the shared program
    3. May execute different sequences of instructions within any part of the shared program. Answer: 3
  • Using n threads within a single process is more efficient than using n separate processes because the threads share the same code and data (T or F)
    T
  • Using n threads within a single process is more efficient than using n separate processes because only the threads can take advantage of multiple CPUs (T or F)
    F