Operating System-Threads-Galvin

12
THREADS SONALI CHAUHAN SYBSc-IT UDIT

description

 

Transcript of Operating System-Threads-Galvin

Page 1: Operating System-Threads-Galvin

THREADS

SONALI CHAUHAN

SYBSc-IT

UDIT

Page 2: Operating System-Threads-Galvin

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

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

SINGLE AND MULTI THREAD

Page 5: Operating System-Threads-Galvin

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

BENEFITS

Responsiveness

Resource Sharing

Economy

Utilization of MP Architectures

Page 7: Operating System-Threads-Galvin

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

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

Multithreading Models

Many-to-One

One-to-One

Many-to-Many

Page 10: Operating System-Threads-Galvin

MANY-TO-ONE

Many user-level threads mapped to single kernel thread

Page 11: Operating System-Threads-Galvin

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

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