Operating System-Threads-Galvin

26,292
-1

Published on

Published in: Education, Technology
1 Comment
9 Likes
Statistics
Notes
No Downloads
Views
Total Views
26,292
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
758
Comments
1
Likes
9
Embeds 0
No embeds

No notes for slide

Operating System-Threads-Galvin

  1. 1. THREADS SONALI CHAUHAN SYBSc-IT UDIT
  2. 2. INTRODUCTION <ul><li>A thread is contained inside a process and different threads in the same process share some resources (most commonly memory ), while different processes do not. </li></ul><ul><li>Process and threads </li></ul>
  3. 3. <ul><li>On a single processor, multithreading generally occurs by as in multitasking , the processor switches between different threads. </li></ul><ul><li>This context switching generally happens frequently enough that the user perceives the threads or tasks to be running at the same time. </li></ul><ul><li>On a multiprocessor or multi-core system, the threads or tasks actually do run at the same time, with each processor or core running a particular thread or task </li></ul>
  4. 4. SINGLE AND MULTI THREAD
  5. 5. <ul><li>Single Thread </li></ul><ul><ul><li>Has single thread of control </li></ul></ul><ul><ul><li>It allows the process to perform only 1 task at a time. </li></ul></ul><ul><li>Multi thread </li></ul><ul><ul><li>Has many threads </li></ul></ul><ul><ul><li>Simultaneous execution of different task </li></ul></ul>
  6. 6. BENEFITS <ul><li>Responsiveness </li></ul><ul><li>Resource Sharing </li></ul><ul><li>Economy </li></ul><ul><li>Utilization of MP Architectures </li></ul>
  7. 7. User Threads <ul><li>Thread management done by user-level threads library </li></ul><ul><ul><li>Thread creation, scheduling, are done in user level </li></ul></ul><ul><li>Fast to create and manage </li></ul><ul><li>Drawback: </li></ul><ul><ul><li>If kernel is single thread, then user level thread performing a blocking system call will cause entire process to block </li></ul></ul>
  8. 8. KERNEL THREAD <ul><li>Supported by OS </li></ul><ul><ul><li>Thread creation, scheduling, are done in user level by kernel </li></ul></ul><ul><li>Thread management is performed by os, thus kernel thread are slow. </li></ul><ul><li>If thread perform blocking system call, kernel can schedule another thread in application for execution </li></ul>
  9. 9. Multithreading Models <ul><li>Many-to-One </li></ul><ul><li>One-to-One </li></ul><ul><li>Many-to-Many </li></ul>
  10. 10. MANY-TO-ONE <ul><li>Many user-level threads mapped to single kernel thread </li></ul>
  11. 11. ONE-TO-ONE MODEL <ul><li>Each user-level thread maps to kernel thread </li></ul><ul><li>Allow anther thread to run if block </li></ul><ul><li>Run parallel </li></ul><ul><li>Drawback: along with user thread kernel thread shld be created. </li></ul>
  12. 12. MANY-TO-MANY <ul><li>Allows many user level threads to be mapped to many kernel threads </li></ul><ul><li>Allows the operating system to create a sufficient number of kernel threads </li></ul>

×