Understand Process Management• Threads                                            1
HOME     PREVIOUS TOPICNEXTPREVIOUS QUESTION PAPERSFOR OSCPP TUTORIALS                           2
RecapIn the last class, you have learnt• Relationship between Processes• Reasons for providing an environment that allows ...
ObjectivesOn completion of this class, you would be able to  know• Definition of Thread• Benefits of Multithread programmi...
Thread Structure• A thread is a light weight process (LWP)• Basic unit of CPU utilization• Shares other threads belonging ...
Thread StructureThread comprises of• Thread id• Program counter• Register counter• Register set• Stack                    ...
Thread Structure• Process having multiple threads of control, can perform more  than one task at a time• Threads operate, ...
Thread StatesThread states• New• Ready• Blocked• Running• Terminated                                8
ThreadsSingle threaded process• A traditional (or heavy weight) Process that has a single thread  of controlMulti threaded...
Single and Multi Thread Process                                                     Thread  Single Thread Process       Mu...
Benefits of Multithreading ProgrammingResponsiveness• Allows a program to continue even if a part of it is   blocked or pe...
Benefits of Multithreading ProgrammingEconomy• Threads share resources of the process to which   they belong• Hence it is ...
Benefits of Multithreading ProgrammingUtilization of multiprocessor architectures•   Benefits of multithreading can be gre...
Multi Threading Model• An operating system support multiple threads of execution in  one process• Support for threads may ...
One process one thread                One process multiple thread             Fig.1 (a)                              Fig.2...
Multithreading ModelsMany-to-one Model• Maps many user-level threads to one kernel thread• Green threads-a thread library ...
Multithreading ModelsOne-to-One Model• Maps each user thread to a kernel thread• Windows 95/98/NT/2000/XP implement the on...
Multithreading ModelsMany-to-Many Model• Multiplexes many user level threads to a smaller or equal  number of kernel threa...
SummaryIn this class, you have learnt•   A thread is a basic unit of CPU utilization•   A thread is a light weight process...
Frequently Asked Questions1.   Write short notes on threads2.   Explain the different multithreading models               ...
Other subject materials•   Web designing•   Micro processors•   C++ tutorials•   javahome
QuizState whether the following statements are true or false1. Thread is a light weight process    a) True    b) False2. T...
Upcoming SlideShare
Loading in …5
×

15 threads

418 views
307 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
418
On SlideShare
0
From Embeds
0
Number of Embeds
21
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

15 threads

  1. 1. Understand Process Management• Threads 1
  2. 2. HOME PREVIOUS TOPICNEXTPREVIOUS QUESTION PAPERSFOR OSCPP TUTORIALS 2
  3. 3. RecapIn the last class, you have learnt• Relationship between Processes• Reasons for providing an environment that allows Process cooperation 3
  4. 4. ObjectivesOn completion of this class, you would be able to know• Definition of Thread• Benefits of Multithread programming• Multithreading Models 4
  5. 5. Thread Structure• A thread is a light weight process (LWP)• Basic unit of CPU utilization• Shares other threads belonging to the same process its code section, data section and other resources• Threads created for a particular process are known as sibling threads 5
  6. 6. Thread StructureThread comprises of• Thread id• Program counter• Register counter• Register set• Stack 6
  7. 7. Thread Structure• Process having multiple threads of control, can perform more than one task at a time• Threads operate, in many respects, in the same manner as processes• Like processes threads can share CPU, but only one thread at a time is active• Thread can create child threads• Threads are not independent of one another• This structure does not provide protection between threads as they can read or write over any other thread 7
  8. 8. Thread StatesThread states• New• Ready• Blocked• Running• Terminated 8
  9. 9. ThreadsSingle threaded process• A traditional (or heavy weight) Process that has a single thread of controlMulti threaded process• A process which has several threads of control• It can do more than one task at a time 9
  10. 10. Single and Multi Thread Process Thread Single Thread Process Multi Thread Process Fig.1 10
  11. 11. Benefits of Multithreading ProgrammingResponsiveness• Allows a program to continue even if a part of it is blocked or performing a lengthy operationResource sharing• Threads share the memory and the resources of the process to which they belong• Allows an application to have several different threads of activity within the same address space 11
  12. 12. Benefits of Multithreading ProgrammingEconomy• Threads share resources of the process to which they belong• Hence it is more economical to create and conduct switch threads 12
  13. 13. Benefits of Multithreading ProgrammingUtilization of multiprocessor architectures• Benefits of multithreading can be greatly increased in a multiprocessor architecture where threads may be running in parallel on different processors• Multithreading increases concurrency on a multi- CPU machine 13
  14. 14. Multi Threading Model• An operating system support multiple threads of execution in one process• Support for threads may be provided at either the user level or by the kernel• User threads are supported above the kernel and are managed without kernel support• Kernel threads are supported and managed directly by operating system• Windows XP. Solaris, True64 UNIX - support kernel threads 14
  15. 15. One process one thread One process multiple thread Fig.1 (a) Fig.2 (b)Multiple process, one thread per process Multiple process, multiple threads per process Fig.3 (c) Fig.4 (d) Fig: multithreading model 15
  16. 16. Multithreading ModelsMany-to-one Model• Maps many user-level threads to one kernel thread• Green threads-a thread library available for Solaris users this model Fig.2 16
  17. 17. Multithreading ModelsOne-to-One Model• Maps each user thread to a kernel thread• Windows 95/98/NT/2000/XP implement the one-to-one model User thread Kernel thread Fig.3 17
  18. 18. Multithreading ModelsMany-to-Many Model• Multiplexes many user level threads to a smaller or equal number of kernel threads. User thread Kernel thread Fig.4 18
  19. 19. SummaryIn this class, you have learnt• A thread is a basic unit of CPU utilization• A thread is a light weight process• A thread shares with peer threads its code section data section and other resources• Extensive sharing makes CPU switching among peer threads and thread creation inexpensive 19
  20. 20. Frequently Asked Questions1. Write short notes on threads2. Explain the different multithreading models 20
  21. 21. Other subject materials• Web designing• Micro processors• C++ tutorials• javahome
  22. 22. QuizState whether the following statements are true or false1. Thread is a light weight process a) True b) False2. Threads can communicate with each other a) True b) False3. A thread needs __________________ Less no. of resources4. A single process _____________________ Supports multiple threads 22

×