SlideShare a Scribd company logo
1 of 14
Represnted By 
Ezzat gul
The ability of an operating system to execute 
different parts of a program, called threads, 
simultaneously. The programmer must 
carefully design the program in such a way 
that all the threads can run at the same time 
without interfering with each other.
 main () 
 {..... 
 f1(.........) ; 
 f2(..........) ; 
 } 
 f1(.............) 
 f2(..............) 
 } 
Thread 
Process 
terminated 
f1 
f2
 main () 
 { 
 ........ 
 Thread (t1,f1) ; 
 Thread (t2,f2) ; 
 ......... 
 } 
 f1(.......) 
 {...........} 
 f2(........) 
 {..........} 
Process Address 
Space 
f1 f2 
PC 
PC
Threads compared with 
processes : 
Processes carry considerable state information, 
where multiple threads within a process share state 
as well as memory and other resources Processes 
have separate address space, where threads share 
their address space Context switching between 
threads in the same process is typically faster than 
context switching between processes. Processes are 
typically independent, while threads exist as subsets 
of a process.
Advantages of Multi-threading 
: 
If a thread can not use all the computing resources of 
the CPU (because instructions depend on each other's 
result), running another thread permits to not leave 
these idle. If several threads work on the same set of 
data, they can actually share its caching, leading to 
better cache usage or synchronization on its values. If a 
thread gets a lot of cache misses, the other thread(s) 
can continue, taking advantage of the unused 
computing resources, which thus can lead to faster 
overall execution, as these resources would have been 
idle if only a single thread was executed.
Two levels of thread : 
Two levels of thread User level(for user 
thread) Kernel level(for kernel thread)?
User Threads : 
User threads are supported above the kernel and are 
implemented by a thread library at the user level. The 
library provides support for thread creation, scheduling, 
and management with no support from the 
kernel.Because the kernel is unaware of user-level 
threads, all thread creation and scheduling are done in 
user space without the need for kernel intervention. 
User-level threads are generally fast to create and 
manage User-thread libraries include POSIX 
Pthreads,Mach C-threads,and Solaris 2 UI-threads.
Kernel Threads : 
Kernel threads are supported directly by 
the operating system:The kernel performs 
thread creation, scheduling, and 
management in kernel space. Because 
thread management is done by the 
operating system, kernel threads are 
generally slower to create and manage 
than are user threads. Most operating 
systems-including Windows NT, 
Windows 2000, Solaris 2, BeOS, and 
Tru64 UNIX (formerly Digital UN1X)-
Multi-threading Models : 
There are three models for thread libraries, 
each with its own trade-offs many threads on 
one LWP (many-to-one)? one thread per LWP 
(one-to-one)? many threads on many LWPs 
(many-to-many)?
 In this model, the library maps all 
threads to a single lightweight process 
 Advantages: 
 totally portable 
 easy to do with few systems 
dependencies
 In this model, the library maps each 
thread to a different lightweight 
process 
 Advantages: 
 can exploit parallelism, blocking 
system calls 
 Disadvantages: 
 thread creation involves LWP 
creation 
 each thread takes up kernel 
resources 
 limiting the number of total threads 
 Used in LinuxThreads and other 
systems where LWP creation is not too 
expensive
 In this model, the library has 
two kinds of threads: bound and 
unbound 
 bound threads are mapped 
each to a single lightweight 
process 
 unbound threads may be 
mapped to the same LWP 
 Probably the best of both worlds 
 Used in the Solaris 
implementation of Pthreads 
(and several other Unix 
implementations)
OS Threads Explained - User vs Kernel Level Threads

More Related Content

What's hot

What's hot (20)

Thread management
Thread management Thread management
Thread management
 
Networking threads
Networking threadsNetworking threads
Networking threads
 
Lecture 9 -_pthreads-linux_threads
Lecture 9 -_pthreads-linux_threadsLecture 9 -_pthreads-linux_threads
Lecture 9 -_pthreads-linux_threads
 
Operating System-Threads-Galvin
Operating System-Threads-GalvinOperating System-Threads-Galvin
Operating System-Threads-Galvin
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Threads
ThreadsThreads
Threads
 
Operating Systems 1 (7/12) - Threads
Operating Systems 1 (7/12) - ThreadsOperating Systems 1 (7/12) - Threads
Operating Systems 1 (7/12) - Threads
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
Os
OsOs
Os
 
Operating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingOperating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programming
 
Posix threads(asha)
Posix threads(asha)Posix threads(asha)
Posix threads(asha)
 
An Introduction to threads
An Introduction to threadsAn Introduction to threads
An Introduction to threads
 
Ch4 Threads
Ch4 ThreadsCh4 Threads
Ch4 Threads
 
Thread scheduling in Operating Systems
Thread scheduling in Operating SystemsThread scheduling in Operating Systems
Thread scheduling in Operating Systems
 
Threads .ppt
Threads .pptThreads .ppt
Threads .ppt
 
Chapter 4 - Threads
Chapter 4 - ThreadsChapter 4 - Threads
Chapter 4 - Threads
 
Thread
ThreadThread
Thread
 
Multithreading
Multithreading Multithreading
Multithreading
 
OS - Thread
OS - ThreadOS - Thread
OS - Thread
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 

Viewers also liked

Viewers also liked (17)

Concurrency control ms neeti
Concurrency control ms neetiConcurrency control ms neeti
Concurrency control ms neeti
 
System Data Modelling Tools
System Data Modelling ToolsSystem Data Modelling Tools
System Data Modelling Tools
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Transaction and concurrency control
Transaction and concurrency controlTransaction and concurrency control
Transaction and concurrency control
 
Paging-R.D.Sivakumar
Paging-R.D.SivakumarPaging-R.D.Sivakumar
Paging-R.D.Sivakumar
 
Normalization in Database
Normalization in DatabaseNormalization in Database
Normalization in Database
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Exception handling in Java
Exception handling in JavaException handling in Java
Exception handling in Java
 
DbMs
DbMsDbMs
DbMs
 
OSI Model | Computer Science
OSI Model | Computer ScienceOSI Model | Computer Science
OSI Model | Computer Science
 
Exception Handling In Java
Exception Handling In JavaException Handling In Java
Exception Handling In Java
 
Normalization
NormalizationNormalization
Normalization
 
Test Life Cycle
Test Life CycleTest Life Cycle
Test Life Cycle
 
Transaction & Concurrency Control
Transaction & Concurrency ControlTransaction & Concurrency Control
Transaction & Concurrency Control
 
Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)
 
OSI Model
OSI ModelOSI Model
OSI Model
 
Software testing ppt
Software testing pptSoftware testing ppt
Software testing ppt
 

Similar to OS Threads Explained - User vs Kernel Level Threads

Similar to OS Threads Explained - User vs Kernel Level Threads (20)

Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programming
 
4.Process.ppt
4.Process.ppt4.Process.ppt
4.Process.ppt
 
Sucet os module_2_notes
Sucet os module_2_notesSucet os module_2_notes
Sucet os module_2_notes
 
Concept of thread, multi thread, tcb
Concept of thread, multi thread, tcbConcept of thread, multi thread, tcb
Concept of thread, multi thread, tcb
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptx
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"
 
Threading.pptx
Threading.pptxThreading.pptx
Threading.pptx
 
Thread
ThreadThread
Thread
 
Chapter 6 os
Chapter 6 osChapter 6 os
Chapter 6 os
 
Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2
 
Topic 4- processes.pptx
Topic 4- processes.pptxTopic 4- processes.pptx
Topic 4- processes.pptx
 
Introto netthreads-090906214344-phpapp01
Introto netthreads-090906214344-phpapp01Introto netthreads-090906214344-phpapp01
Introto netthreads-090906214344-phpapp01
 
Chapter04 new
Chapter04 newChapter04 new
Chapter04 new
 
Threads
ThreadsThreads
Threads
 
OSCh5
OSCh5OSCh5
OSCh5
 
CH04.pdf
CH04.pdfCH04.pdf
CH04.pdf
 
Wiki 2
Wiki 2Wiki 2
Wiki 2
 
Intro To .Net Threads
Intro To .Net ThreadsIntro To .Net Threads
Intro To .Net Threads
 
thread os.pptx
thread os.pptxthread os.pptx
thread os.pptx
 
Ch04 threads
Ch04 threadsCh04 threads
Ch04 threads
 

Recently uploaded

Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 

Recently uploaded (20)

Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 

OS Threads Explained - User vs Kernel Level Threads

  • 2. The ability of an operating system to execute different parts of a program, called threads, simultaneously. The programmer must carefully design the program in such a way that all the threads can run at the same time without interfering with each other.
  • 3.  main ()  {.....  f1(.........) ;  f2(..........) ;  }  f1(.............)  f2(..............)  } Thread Process terminated f1 f2
  • 4.  main ()  {  ........  Thread (t1,f1) ;  Thread (t2,f2) ;  .........  }  f1(.......)  {...........}  f2(........)  {..........} Process Address Space f1 f2 PC PC
  • 5. Threads compared with processes : Processes carry considerable state information, where multiple threads within a process share state as well as memory and other resources Processes have separate address space, where threads share their address space Context switching between threads in the same process is typically faster than context switching between processes. Processes are typically independent, while threads exist as subsets of a process.
  • 6. Advantages of Multi-threading : If a thread can not use all the computing resources of the CPU (because instructions depend on each other's result), running another thread permits to not leave these idle. If several threads work on the same set of data, they can actually share its caching, leading to better cache usage or synchronization on its values. If a thread gets a lot of cache misses, the other thread(s) can continue, taking advantage of the unused computing resources, which thus can lead to faster overall execution, as these resources would have been idle if only a single thread was executed.
  • 7. Two levels of thread : Two levels of thread User level(for user thread) Kernel level(for kernel thread)?
  • 8. User Threads : User threads are supported above the kernel and are implemented by a thread library at the user level. The library provides support for thread creation, scheduling, and management with no support from the kernel.Because the kernel is unaware of user-level threads, all thread creation and scheduling are done in user space without the need for kernel intervention. User-level threads are generally fast to create and manage User-thread libraries include POSIX Pthreads,Mach C-threads,and Solaris 2 UI-threads.
  • 9. Kernel Threads : Kernel threads are supported directly by the operating system:The kernel performs thread creation, scheduling, and management in kernel space. Because thread management is done by the operating system, kernel threads are generally slower to create and manage than are user threads. Most operating systems-including Windows NT, Windows 2000, Solaris 2, BeOS, and Tru64 UNIX (formerly Digital UN1X)-
  • 10. Multi-threading Models : There are three models for thread libraries, each with its own trade-offs many threads on one LWP (many-to-one)? one thread per LWP (one-to-one)? many threads on many LWPs (many-to-many)?
  • 11.  In this model, the library maps all threads to a single lightweight process  Advantages:  totally portable  easy to do with few systems dependencies
  • 12.  In this model, the library maps each thread to a different lightweight process  Advantages:  can exploit parallelism, blocking system calls  Disadvantages:  thread creation involves LWP creation  each thread takes up kernel resources  limiting the number of total threads  Used in LinuxThreads and other systems where LWP creation is not too expensive
  • 13.  In this model, the library has two kinds of threads: bound and unbound  bound threads are mapped each to a single lightweight process  unbound threads may be mapped to the same LWP  Probably the best of both worlds  Used in the Solaris implementation of Pthreads (and several other Unix implementations)