Operating System-Threads-Galvin
-
Upload
sonali-chauhan -
Category
Education
-
view
24.043 -
download
7
description
Transcript of Operating System-Threads-Galvin
THREADS
SONALI CHAUHAN
SYBSc-IT
UDIT
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
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
SINGLE AND MULTI THREAD
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
BENEFITS
Responsiveness
Resource Sharing
Economy
Utilization of MP Architectures
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
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
Multithreading Models
Many-to-One
One-to-One
Many-to-Many
MANY-TO-ONE
Many user-level threads mapped to single kernel thread
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.
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