Multithreading and Thread Libraries: An In-depth Look, Slides of Operating Systems

An overview of multithreading, its models, thread libraries, and related issues. It covers various operating systems, including windows xp and linux, and their thread implementations. The benefits of multithreading, such as responsiveness and resource sharing, are discussed. The document also explores the challenges of multicore programming and the importance of user and kernel threads.

Typology: Slides

2012/2013

Uploaded on 04/25/2013

baidehi
baidehi 🇮🇳

4.4

(14)

101 documents

1 / 31

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 7
Chapter 4: Threads (cont)
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f

Partial preview of the text

Download Multithreading and Thread Libraries: An In-depth Look and more Slides Operating Systems in PDF only on Docsity!

Lecture 7

Chapter 4: Threads (cont)

Chapter 4: Threads

  • Overview
  • Multithreading Models
  • Thread Libraries
  • Threading Issues
  • Operating System Examples
  • Windows XP Threads
  • Linux Threads

ex: Solaris, Mach, Windows

ex: MS-DOS ex: Java VM ex: early UNIX

uniprogramming

multiprogramming

Process-Thread relationship

Single and Multithreaded Processes

Benefits

  • Responsiveness : Continue even if part of an application is blocked due to I/O - Allow user interaction in one thread while image is loading in another.
  • Resource Sharing : Memory / resource sharing is by default with threads. - Several different threads of activity within the same address space.
  • Economy : It is more economical to create andDocsity.com

Multicore Scalability

Parallel Execution on a Multicore System

Concurrent Execution on a Single-core System

User Threads

  • Thread management done by user-level threads library
  • Three primary thread libraries:
    • POSIX Pthreads
    • Win32 threads
    • Java threads

Kernel Threads

  • Supported by the Kernel
  • Examples
    • Windows XP/
    • Solaris
    • Linux
    • Tru64 UNIX
    • Mac OS X

Many-to-One

  • Many user-level threads mapped to single kernel thread.
  • Thread management is done by the thread library in user space, - Is efficient, - But, entire process will block is a thread makes a blocking system call.
  • Only one thread can access the kernel at a time, Docsity.com

One-to-One

  • Each user-level thread maps to kernel thread.
  • Provides more concurrency.
    • No blocking due to another thread.
    • Threads may run in parallel on multiprocessors.
  • Creating a user thread requires creating the corresponding kernel thread. - Hence, OSes limit the number of threads.

Two-level Model

  • Similar to many-to-many, except that it allows a user thread to be bound to kernel thread.
  • Examples
    • IRIX
    • HP-UX
    • Tru64 UNIX
    • Solaris 8 and earlier

Pthreads

  • May be provided either as user-level or kernel-level
  • A POSIX standard (IEEE 1003.1c) API for thread creation and synchronization
  • API specifies behavior of the thread library, implementation is up to development of the library

Java Threads

  • Java threads are managed by the JVM
  • Typically implemented using the threads model provided by underlying OS
  • Java threads may be created by:
    • Extending Thread class
    • Implementing the Runnable interface
      • Must define run() method
      • Call start() method to initialize a thread
      • Use join() method to wait for a thread Docsity.com