1 Chapter 4 Threads Threads: Resource ownership and execution.

Slides:



Advertisements
Similar presentations
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Advertisements

Chapter 4 Threads Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William.
Threads, SMP, and Microkernels
Operating Systems: Internals and Design Principles
Chapter 3 Process Description and Control
Threads, SMP, and Microkernels Chapter 4. Process Resource ownership - process is allocated a virtual address space to hold the process image Scheduling/execution-
Chapter 4 Threads, SMP, and Microkernels Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design.
Computer Systems/Operating Systems - Class 8
Day 10 Threads. Threads and Processes  Process is seen as two entities Unit of resource allocation (process or task) Unit of dispatch or scheduling (thread.
Threads Irfan Khan Myo Thein What Are Threads ? a light, fine, string like length of material made up of two or more fibers or strands of spun cotton,
Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads.
1 Threads, SMP, and Microkernels Chapter 4. 2 Process: Some Info. Motivation for threads! Two fundamental aspects of a “process”: Resource ownership Scheduling.
Threads, SMP, and Microkernels
UNIX Process Creation Every process, except process 0, is created by the fork() system call fork() allocates entry in process table and assigns a unique.
Threads. Processes and Threads  Two characteristics of “processes” as considered so far: Unit of resource allocation Unit of dispatch  Characteristics.
A. Frank - P. Weisberg Operating Systems Introduction to Tasks/Threads.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
Threads Chapter 4. Modern Process & Thread –Process is an infrastructure in which execution takes place  (address space + resources) –Thread is a program.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
Processes Part I Processes & Threads* *Referred to slides by Dr. Sanjeev Setia at George Mason University Chapter 3.
Process Description and Control. Process concepts n Definitions – replaces task, job – program in execution – entity that can be assigned to and executed.
Chapter 4 Threads, SMP, and Microkernels Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E.
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Operating Systems Lecture 09: Threads (Chapter 4)
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
Multithreading Allows application to split itself into multiple “threads” of execution (“threads of execution”). OS support for creating threads, terminating.
Threads, SMP, and Microkernels Chapter 4. 2 Outline n Threads n Symmetric Multiprocessing (SMP) n Microkernel n Linux Threads.
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Operating System 4 THREADS, SMP AND MICROKERNELS
Threads, Thread management & Resource Management.
Chapter 4 Threads, SMP, and Microkernels Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design.
1 Threads, SMP, and Microkernels Chapter 4. 2 Focus and Subtopics Focus: More advanced concepts related to process management : Resource ownership vs.
Processes and Threads Processes have two characteristics: – Resource ownership - process includes a virtual address space to hold the process image – Scheduling/execution.
Threads, SMP, and Microkernels Chapter 4. Process Resource ownership - process is allocated a virtual address space to hold the process image Scheduling/execution-
Threads G.Anuradha (Reference : William Stallings)
1 Threads, SMP, and Microkernels Chapter 4. 2 Process Resource ownership: process includes a virtual address space to hold the process image (fig 3.16)
OPERATING SYSTEM SUPPORT DISTRIBUTED SYSTEMS CHAPTER 6 Lawrence Heyman July 8, 2002.
Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model.
1 Threads, SMP, and Microkernels Chapter Multithreading Operating system supports multiple threads of execution within a single process MS-DOS.
1 Lecture 4: Threads Advanced Operating System Fall 2010.
Lecture 5: Threads process as a unit of scheduling and a unit of resource allocation processes vs. threads what to program with threads why use threads.
Operating System 4 THREADS, SMP AND MICROKERNELS.
1 Process Description and Control Chapter 2. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
Department of Computer Science and Software Engineering
Thread By Group III Kathryn Bean and Wafa’ Jaffal.
Chapter 4 Threads Seventh Edition By William Stallings Operating Systems: Internals and Design Principles.
Operating Systems: Internals and Design Principles
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
Module 2.0: Threads.
Threads, Thread management & Resource Management.
Threads-Process Interaction. CONTENTS  Threads  Process interaction.
Linux Development Lecture
Chapter 4 Threads, SMP, and Microkernels Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E.
1 Threads, SMP, and Microkernels Chapter 4. 2 Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-
Threads, SMP and Microkernels Process vs. thread: –Unit of resource ownership (process has virtual address space, memory, I/O channels, files) –Unit of.
Threads, SMP, and Microkernels Chapter 4. Processes and Threads Operating systems use processes for two purposes - Resource allocation and resource ownership.
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 4 Threads.
Principles of Operating Systems Lecture 8
Threads, SMP, and Microkernels
Chapter 15, Exploring the Digital Domain
Mid Term review CSC345.
Threads Chapter 4.
Lecture 4- Threads, SMP, and Microkernels
Operating System 4 THREADS, SMP AND MICROKERNELS
Threads and Concurrency
Threads Chapter 4.
Chapter 4 Threads, SMP, and Microkernels
Operating Systems Concepts
Presentation transcript:

1 Chapter 4 Threads Threads: Resource ownership and execution

2 Processes and Threads Processes have two characteristics: –Resource ownership – a process includes an address space to hold the process image and may be allocated control or ownership of resources –Scheduling/execution – process execution follows an execution path that may be interleaved with other processes These two characteristics are treated independently by the operating system

3 Processes and Threads The unit of dispatching is referred to as a thread or lightweight process The unit of resource ownership is referred to as a process or task

4 Multithreading The ability of an OS to support multiple, concurrent paths of execution within a single process.

5 Single Thread Approaches MS-DOS supports a single user process and a single thread Some UNIX, support multiple user processes but only support one thread per process

6 Multithreading Java run-time environment is a single process with multiple threads Multiple processes and threads are found in Windows, Solaris, and many modern versions of UNIX

7 Processes In a multithreaded environment, a process is defined as –a unit of resource allocation: a virtual address space which holds the process image –a unit of protection: protected access to processors, other processes (for IPC), files, I/O resources

8 One or More Threads in Process Each thread has –An execution state (running, ready, etc.) –Saved thread context when not running –An execution stack –Some per-thread static storage for local variables –Access to the memory and resources of its process (all threads of a process share this)

9 One view… One way to view a thread is as an independent program counter operating within a process.

10 Threads vs. processes

11 Threads vs. processes The thread control block contains register values, priority, and other thread-related state information. All threads of a process share the state and resources of that process. –reside in the same address space –have access to the same data when one thread alters a data, other threads see the results when one thread opens a file, other threads can also access that file

12 Benefits of Threads Takes less time to create a new thread than a process (can be 10 times faster) Less time to terminate a thread than a process Switching between two threads takes less time that switching processes Threads can communicate with each other –without invoking the kernel

13 Benefits of Threads If an application is implemented as a set of related units of execution, it is far more efficient to do so as a collection of threads rather than a collection of separate processes

14 Example Applications of Threads In a file server, a new thread can be spawned for the file management program per each new file request  multiple threads within the same process can be executing simultaneously on different processors In a spreadsheet program, one thread could read user input while another thread executes user commands In a word processor, a thread can be created to do periodic backup asynchronously In a multithreaded process, one thread can compute one batch of data while another thread reads the next batch from an I/O device

15 Threads vs. processes Like processes, threads have execution states –Running, Ready, and Blocked Some states are process-level –Suspend: if a process is swapped out, all of its threads are necessarily swapped out because they all share the address space of the process

16 Threads vs. processes Like processes, thread may synchronize with one another. –Any alteration of a resource by one thread affects other threads in the same process consider two threads each try to add an element to a linked list at the same time

17 Example: Remote Procedure Call Consider: –A program that performs two remote procedure calls (RPCs) to two different hosts to obtain a combined result.

18 RPC Using Single Thread The program has to wait for a response from each server in turn.

19 RPC Using One Thread per Server The program waits concurrently for the two replies.

20 Multithreading on a Uniprocessor Interleaving of multiple threads within multiple processes on a uniprocessor