operating system-threads-galvin
DESCRIPTION
TRANSCRIPT
![Page 1: Operating System-Threads-Galvin](https://reader036.vdocuments.us/reader036/viewer/2022082916/54bd46494a7959ad338b4618/html5/thumbnails/1.jpg)
THREADS
SONALI CHAUHAN
SYBSc-IT
UDIT
![Page 2: Operating System-Threads-Galvin](https://reader036.vdocuments.us/reader036/viewer/2022082916/54bd46494a7959ad338b4618/html5/thumbnails/2.jpg)
INTRODUCTION
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.
Process and threads
![Page 3: Operating System-Threads-Galvin](https://reader036.vdocuments.us/reader036/viewer/2022082916/54bd46494a7959ad338b4618/html5/thumbnails/3.jpg)
On a single processor, multithreading generally occurs by as in multitasking, the processor switches between different threads.
This context switching generally happens frequently enough that the user perceives the threads or tasks to be running at the same time.
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
![Page 4: Operating System-Threads-Galvin](https://reader036.vdocuments.us/reader036/viewer/2022082916/54bd46494a7959ad338b4618/html5/thumbnails/4.jpg)
SINGLE AND MULTI THREAD
![Page 5: Operating System-Threads-Galvin](https://reader036.vdocuments.us/reader036/viewer/2022082916/54bd46494a7959ad338b4618/html5/thumbnails/5.jpg)
Single Thread Has single thread of control It allows the process to perform only 1
task at a time. Multi thread
Has many threads Simultaneous execution of different task
![Page 6: Operating System-Threads-Galvin](https://reader036.vdocuments.us/reader036/viewer/2022082916/54bd46494a7959ad338b4618/html5/thumbnails/6.jpg)
BENEFITS
Responsiveness
Resource Sharing
Economy
Utilization of MP Architectures
![Page 7: Operating System-Threads-Galvin](https://reader036.vdocuments.us/reader036/viewer/2022082916/54bd46494a7959ad338b4618/html5/thumbnails/7.jpg)
User Threads
Thread management done by user-level threads library Thread creation, scheduling, are done in
user level Fast to create and manage Drawback:
If kernel is single thread, then user level thread performing a blocking system call will cause entire process to block
![Page 8: Operating System-Threads-Galvin](https://reader036.vdocuments.us/reader036/viewer/2022082916/54bd46494a7959ad338b4618/html5/thumbnails/8.jpg)
KERNEL THREAD
Supported by OS Thread creation, scheduling, are done in
user level by kernel Thread management is performed by
os, thus kernel thread are slow. If thread perform blocking system call,
kernel can schedule another thread in application for execution
![Page 9: Operating System-Threads-Galvin](https://reader036.vdocuments.us/reader036/viewer/2022082916/54bd46494a7959ad338b4618/html5/thumbnails/9.jpg)
Multithreading Models
Many-to-One
One-to-One
Many-to-Many
![Page 10: Operating System-Threads-Galvin](https://reader036.vdocuments.us/reader036/viewer/2022082916/54bd46494a7959ad338b4618/html5/thumbnails/10.jpg)
MANY-TO-ONE
Many user-level threads mapped to single kernel thread
![Page 11: Operating System-Threads-Galvin](https://reader036.vdocuments.us/reader036/viewer/2022082916/54bd46494a7959ad338b4618/html5/thumbnails/11.jpg)
ONE-TO-ONE MODEL
Each user-level thread maps to kernel thread Allow anther thread to run if block Run parallel Drawback: along with user thread kernel
thread shld be created.
![Page 12: Operating System-Threads-Galvin](https://reader036.vdocuments.us/reader036/viewer/2022082916/54bd46494a7959ad338b4618/html5/thumbnails/12.jpg)
MANY-TO-MANY
Allows many user level threads to be mapped to many kernel threads
Allows the operating system to create a sufficient number of kernel threads