Chapter 5: Threads I Overview I Multithreading Models I Threading - - PDF document

chapter 5 threads
SMART_READER_LITE
LIVE PREVIEW

Chapter 5: Threads I Overview I Multithreading Models I Threading - - PDF document

Chapter 5: Threads I Overview I Multithreading Models I Threading Issues I Pthreads I Solaris 2 Threads I Windows 2000 Threads I Linux Threads I Java Threads Silberschatz, Galvin and Gagne 2002 Operating System Concepts 5.1 Single and


slide-1
SLIDE 1

1

Silberschatz, Galvin and Gagne 2002 5.1 Operating System Concepts

Chapter 5: Threads

I Overview I Multithreading Models I Threading Issues I Pthreads I Solaris 2 Threads I Windows 2000 Threads I Linux Threads I Java Threads

Silberschatz, Galvin and Gagne 2002 5.2 Operating System Concepts

Single and Multithreaded Processes

slide-2
SLIDE 2

2

Silberschatz, Galvin and Gagne 2002 5.3 Operating System Concepts

Benefits

I Responsiveness I Resource Sharing I Economy I Utilization of MP Architectures

Silberschatz, Galvin and Gagne 2002 5.4 Operating System Concepts

User Threads

I Thread management done by user-level threads library I Examples

  • POSIX Pthreads
  • Mach C-threads
  • Solaris threads
slide-3
SLIDE 3

3

Silberschatz, Galvin and Gagne 2002 5.5 Operating System Concepts

Kernel Threads

I Supported by the Kernel I Examples

  • Windows 95/98/NT/2000
  • Solaris
  • Tru64 UNIX
  • BeOS
  • Linux

Silberschatz, Galvin and Gagne 2002 5.6 Operating System Concepts

Multithreading Models

I Many-to-One I One-to-One I Many-to-Many

slide-4
SLIDE 4

4

Silberschatz, Galvin and Gagne 2002 5.7 Operating System Concepts

Many-to-One

I Many user-level threads mapped to single kernel thread. I Used on systems that do not support kernel threads.

Silberschatz, Galvin and Gagne 2002 5.8 Operating System Concepts

Many-to-One Model

slide-5
SLIDE 5

5

Silberschatz, Galvin and Gagne 2002 5.9 Operating System Concepts

One-to-One

I Each user-level thread maps to kernel thread. I Examples

  • Windows 95/98/NT/2000
  • OS/2

Silberschatz, Galvin and Gagne 2002 5.10 Operating System Concepts

One-to-one Model

slide-6
SLIDE 6

6

Silberschatz, Galvin and Gagne 2002 5.11 Operating System Concepts

Many-to-Many Model

I Allows many user level threads to be mapped to many

kernel threads.

I Allows the operating system to create a sufficient number

  • f kernel threads.

I Solaris 2 I Windows NT/2000 with the ThreadFiber package

Silberschatz, Galvin and Gagne 2002 5.12 Operating System Concepts

Many-to-Many Model

slide-7
SLIDE 7

7

Silberschatz, Galvin and Gagne 2002 5.13 Operating System Concepts

Threading Issues

I Semantics of fork() and exec() system calls. I Thread cancellation. I Signal handling I Thread pools I Thread specific data

Silberschatz, Galvin and Gagne 2002 5.14 Operating System Concepts

Pthreads

I a POSIX standard (IEEE 1003.1c) API for thread creation

and synchronization.

I API specifies behavior of the thread library,

implementation is up to development of the library.

I Common in UNIX operating systems.

slide-8
SLIDE 8

8

Silberschatz, Galvin and Gagne 2002 5.15 Operating System Concepts

Solaris 2 Threads

Silberschatz, Galvin and Gagne 2002 5.16 Operating System Concepts

Solaris Process

slide-9
SLIDE 9

9

Silberschatz, Galvin and Gagne 2002 5.17 Operating System Concepts

Windows 2000 Threads

I Implements the one-to-one mapping. I Each thread contains

  • a thread id
  • register set
  • separate user and kernel stacks
  • private data storage area

Silberschatz, Galvin and Gagne 2002 5.18 Operating System Concepts

Linux Threads

I Linux refers to them as tasks rather than threads. I Thread creation is done through clone() system call. I Clone() allows a child task to share the address space of

the parent task (process)

slide-10
SLIDE 10

10

Silberschatz, Galvin and Gagne 2002 5.19 Operating System Concepts

Java Threads

I Java threads may be created by:

! Extending Thread class ! Implementing the Runnable interface

I Java threads are managed by the JVM.

Silberschatz, Galvin and Gagne 2002 5.20 Operating System Concepts

Java Thread States