4.Threads

1,407 views

Published on

Senthilkanth,MCA..
The following ppt's full topic covers Operating System for BSc CS, BCA, MSc CS, MCA students..
1.Introduction
2.OS Structures
3.Process
4.Threads
5.CPU Scheduling
6.Process Synchronization
7.Dead Locks
8.Memory Management
9.Virtual Memory
10.File system Interface
11.File system implementation
12.Mass Storage System
13.IO Systems
14.Protection
15.Security
16.Distributed System Structure
17.Distributed File System
18.Distributed Co Ordination
19.Real Time System
20.Multimedia Systems
21.Linux
22.Windows

Published in: Education, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,407
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
91
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

4.Threads

  1. 1. Chapter 4: ThreadsChapter 4: Threads
  2. 2. 4.2 Silberschatz, Galvin and GagneOperating System ConceptsChapter 4: ThreadsChapter 4: ThreadsOverviewMultithreading ModelsThreading IssuesPthreadsWindows XP ThreadsLinux ThreadsJava Threads
  3. 3. 4.3 Silberschatz, Galvin and GagneOperating System ConceptsSingle and Multithreaded ProcessesSingle and Multithreaded Processes
  4. 4. 4.4 Silberschatz, Galvin and GagneOperating System ConceptsBenefitsBenefitsResponsivenessResource SharingEconomyUtilization of MP Architectures
  5. 5. 4.5 Silberschatz, Galvin and GagneOperating System ConceptsUser ThreadsUser ThreadsThread management done by user-level threads libraryThree primary thread libraries:POSIX PthreadsWin32 threadsJava threads
  6. 6. 4.6 Silberschatz, Galvin and GagneOperating System ConceptsKernel ThreadsKernel ThreadsSupported by the KernelExamplesWindows XP/2000SolarisLinuxTru64 UNIXMac OS X
  7. 7. 4.7 Silberschatz, Galvin and GagneOperating System ConceptsMultithreading ModelsMultithreading ModelsMany-to-OneOne-to-OneMany-to-Many
  8. 8. 4.8 Silberschatz, Galvin and GagneOperating System ConceptsMany-to-OneMany-to-OneMany user-level threads mapped to single kernel threadExamples:Solaris Green ThreadsGNU Portable Threads
  9. 9. 4.9 Silberschatz, Galvin and GagneOperating System ConceptsMany-to-One ModelMany-to-One Model
  10. 10. 4.10 Silberschatz, Galvin and GagneOperating System ConceptsOne-to-OneOne-to-OneEach user-level thread maps to kernel threadExamplesWindows NT/XP/2000LinuxSolaris 9 and later
  11. 11. 4.11 Silberschatz, Galvin and GagneOperating System ConceptsOne-to-one ModelOne-to-one Model
  12. 12. 4.12 Silberschatz, Galvin and GagneOperating System ConceptsMany-to-Many ModelMany-to-Many ModelAllows many user level threads to be mapped to many kernelthreadsAllows the operating system to create a sufficient number ofkernel threadsSolaris prior to version 9Windows NT/2000 with the ThreadFiber package
  13. 13. 4.13 Silberschatz, Galvin and GagneOperating System ConceptsMany-to-Many ModelMany-to-Many Model
  14. 14. 4.14 Silberschatz, Galvin and GagneOperating System ConceptsTwo-level ModelTwo-level ModelSimilar to M:M, except that it allows a user thread to bebound to kernel threadExamplesIRIXHP-UXTru64 UNIXSolaris 8 and earlier
  15. 15. 4.15 Silberschatz, Galvin and GagneOperating System ConceptsTwo-level ModelTwo-level Model
  16. 16. 4.16 Silberschatz, Galvin and GagneOperating System ConceptsThreading IssuesThreading IssuesSemantics of fork() and exec() system callsThread cancellationSignal handlingThread poolsThread specific dataScheduler activations
  17. 17. 4.17 Silberschatz, Galvin and GagneOperating System ConceptsSemantics of fork() and exec()Semantics of fork() and exec()Does fork() duplicate only the calling thread or all threads?
  18. 18. 4.18 Silberschatz, Galvin and GagneOperating System ConceptsThread CancellationThread CancellationTerminating a thread before it has finishedTwo general approaches:Asynchronous cancellation terminates the targetthread immediatelyDeferred cancellation allows the target thread toperiodically check if it should be cancelled
  19. 19. 4.19 Silberschatz, Galvin and GagneOperating System ConceptsSignal HandlingSignal HandlingSignals are used in UNIX systems to notify a process that aparticular event has occurredA signal handler is used to process signals1. Signal is generated by particular event2. Signal is delivered to a process3. Signal is handledOptions:Deliver the signal to the thread to which the signal appliesDeliver the signal to every thread in the processDeliver the signal to certain threads in the processAssign a specific threa to receive all signals for the process
  20. 20. 4.20 Silberschatz, Galvin and GagneOperating System ConceptsThread PoolsThread PoolsCreate a number of threads in a pool where they await workAdvantages:Usually slightly faster to service a request with an existingthread than create a new threadAllows the number of threads in the application(s) to bebound to the size of the pool
  21. 21. 4.21 Silberschatz, Galvin and GagneOperating System ConceptsThread Specific DataThread Specific DataAllows each thread to have its own copy of dataUseful when you do not have control over the threadcreation process (i.e., when using a thread pool)
  22. 22. 4.22 Silberschatz, Galvin and GagneOperating System ConceptsScheduler ActivationsScheduler ActivationsBoth M:M and Two-level models require communication tomaintain the appropriate number of kernel threads allocatedto the applicationScheduler activations provide upcalls - a communicationmechanism from the kernel to the thread libraryThis communication allows an application to maintain thecorrect number kernel threads
  23. 23. 4.23 Silberschatz, Galvin and GagneOperating System ConceptsPthreadsPthreadsA POSIX standard (IEEE 1003.1c) API for threadcreation and synchronizationAPI specifies behavior of the thread library,implementation is up to development of the libraryCommon in UNIX operating systems (Solaris, Linux,Mac OS X)
  24. 24. 4.24 Silberschatz, Galvin and GagneOperating System ConceptsWindows XP ThreadsWindows XP ThreadsImplements the one-to-one mappingEach thread containsA thread idRegister setSeparate user and kernel stacksPrivate data storage areaThe register set, stacks, and private storage area are knownas the context of the threadsThe primary data structures of a thread include:ETHREAD (executive thread block)KTHREAD (kernel thread block)TEB (thread environment block)
  25. 25. 4.25 Silberschatz, Galvin and GagneOperating System ConceptsLinux ThreadsLinux ThreadsLinux refers to them as tasks rather than threadsThread creation is done through clone() system callclone() allows a child task to share the address spaceof the parent task (process)
  26. 26. 4.26 Silberschatz, Galvin and GagneOperating System ConceptsJava ThreadsJava ThreadsJava threads are managed by the JVMJava threads may be created by:Extending Thread classImplementing the Runnable interface
  27. 27. 4.27 Silberschatz, Galvin and GagneOperating System ConceptsJava Thread StatesJava Thread States
  28. 28. End of Chapter 4End of Chapter 4

×