Presentation is loading. Please wait.

Presentation is loading. Please wait.

Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.

Similar presentations


Presentation on theme: "Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads."— Presentation transcript:

1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads

2 4.2 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Motivation 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 Process creation is heavy-weight while thread creation is light-weight Can simplify code, increase efficiency Kernels are generally multithreaded

3 4.3 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Multithreaded Server Architecture

4 4.4 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Benefits Responsiveness – may allow continued execution if part of process is blocked, especially important for user interfaces Resource Sharing – threads share resources of process, easier than shared memory or message passing Economy – cheaper than process creation, thread switching lower overhead than context switching Scalability – process can take advantage of multiprocessor architectures

5 4.5 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

6 4.6 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

7 4.7 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

8 4.8 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

9 4.9 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

10 4.10 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

11 4.11 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

12 4.12 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

13 4.13 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

14 4.14 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

15 4.15 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

16 4.16 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

17 4.17 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

18 4.18 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

19 4.19 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

20 4.20 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition User Threads and Kernel Threads 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 Examples – virtually all general purpose operating systems, including: Windows Solaris Linux Tru64 UNIX Mac OS X

21 4.21 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

22 4.22 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

23 4.23 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

24 4.24 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

25 4.25 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

26 4.26 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

27 4.27 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

28 4.28 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

29 4.29 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

30 4.30 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Multithreading Models Many-to-One One-to-One Many-to-Many

31 4.31 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

32 4.32 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

33 4.33 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

34 4.34 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

35 4.35 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

36 4.36 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

37 4.37 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

38 4.38 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

39 4.39 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Threading Issues Semantics of fork() and exec() system calls Signal handling Synchronous and asynchronous Thread cancellation of target thread Asynchronous or deferred Thread-local storage Scheduler Activations

40 4.40 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Signal Handling Signals are used in UNIX systems to notify a process that a particular event has occurred. A signal handler is used to process signals  Signal is generated by particular event  Signal is delivered to a process  Signal is handled by one of two signal handlers:  default  user-defined Every signal has default handler that kernel runs when handling signal User-defined signal handler can override default For single-threaded, signal delivered to process

41 4.41 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Signal Handling (Cont.) Where should a signal be delivered for multi-threaded? Deliver the signal to the thread to which the signal applies Deliver the signal to every thread in the process Deliver the signal to certain threads in the process Assign a specific thread to receive all signals for the process

42 4.42 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Linux Threads Linux refers to them as tasks rather than threads Thread creation is done through clone() system call clone() allows a child task to share the address space of the parent task (process) Flags control behavior n struct task_struct points to process data structures (shared or unique)

43 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition End of Chapter 4


Download ppt "Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads."

Similar presentations


Ads by Google