Threads and Concurrency

Slides:



Advertisements
Similar presentations
Chapter 4 Threads Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William.
Advertisements

Threads, SMP, and Microkernels
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.
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.
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.
1 Chapter 4 Threads Threads: Resource ownership and execution.
Threads, SMP, and Microkernels
Process Concept An operating system executes a variety of programs
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.
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.
Operating System 4 THREADS, SMP AND MICROKERNELS
Threads, Thread management & Resource Management.
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)
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
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.
Department of Computer Science and Software Engineering
Thread By Group III Kathryn Bean and Wafa’ Jaffal.
12/22/ Thread Model for Realizing Concurrency B. Ramamurthy.
Operating Systems: Internals and Design Principles
Threads, Thread management & Resource Management.
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.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
7/9/ Realizing Concurrency using Posix Threads (pthreads) B. Ramamurthy.
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
Threads prepared and instructed by Shmuel Wimer Eng. Faculty, Bar-Ilan University 1July 2016Processes.
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Chapter 4: Threads.
Processes and threads.
Chapter 3: Process Concept
CS 6560: Operating Systems Design
OPERATING SYSTEMS CS3502 Fall 2017
Day 12 Threads.
Chapter 2 Processes and Threads Today 2.1 Processes 2.2 Threads
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 4 Threads.
Nachos Threads and Concurrency
Threads & multithreading
Operating System Concepts
Operating System Concepts
Threads, SMP and Microkernels
Threads, SMP, and Microkernels
Threads Chapter 4.
Lecture 4- Threads, SMP, and Microkernels
Threads Chapter 4.
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Threads Chapter 5 2/17/2019 B.Ramamurthy.
Threads Chapter 5 2/23/2019 B.Ramamurthy.
Still Chapter 2 (Based on Silberchatz’s text and Nachos Roadmap.)
Chapter 4 Threads, SMP, and Microkernels
Threads and Concurrency
Chapter 3: Processes.
Chapter 4: Threads.
CS510 Operating System Foundations
Outline Chapter 2 (cont) Chapter 3: Processes Virtual machines
Chapter 3: Process Concept
CS Introduction to Operating Systems
Presentation transcript:

Threads and Concurrency B.Ramamurthy 1/13/2019 B.Ramamurthy

Thread Unit of work A process has address space, registers, PC and stack (See man fork for the detailed list) A thread has registers, program counter and stack, but the address space is shared with process that started it. This means that a user level thread could be invoked without assistance from the OS. This low overhead is one of the main advantages of threads. If a thread of a process is blocked, the process could go on. Concurrency: Many threads could be operating concurrently, on a multi threaded kernel. User level scheduling is simplified and realistic (bound, unbound, set concurrency, priorities etc.) Communication among the threads is easy and can be carried out without OS intervention. 1/13/2019 B.Ramamurthy

Thread requirements An execution state Independent PC working within the same process. An execution stack. Per-thread static storage for local variables. Access to memory and resources of the creator-process shared with all other threads in the task. Key benefits: less time to create than creating a new process, less time to switch, less time to terminate, more intuitive for implementing concurrency if the application is a collection of execution units. 1/13/2019 B.Ramamurthy

Examples of thread usage Foreground and background work: Consider spreadsheet program: one thread could display menu and get response while another could be processing the request. Increases the perceived speed of the application. Asynchronous processing: Periodic backup (auto-saving) of RAM into disk. A thread could schedule itself to come-alive every 1 minute or so to do this saving concurrently with main processing. Speed execution: In hard-core data-processing simple concurrency can speed up process. Transaction processing: Many independent transactions can be modeled very nicely using threads. Such applications as neural networks, searches, graphics, agent/actor model suit well for thread-implementation. 1/13/2019 B.Ramamurthy

Multithreading Multithreading refers to the ability of the operating system to support multiple threads of execution within a single process. A process is defined as the unit of protection and the unit of resource allocation. It has : a virtual address space, protected access to processors, IPC, files, IO resources. 1/13/2019 B.Ramamurthy

Threads and Processes A thread is a unit of work to a CPU. It is strand of control flow. A traditional UNIX process has a single thread that has sole possession of the process’s memory and resources. Threads within a process are scheduled and execute independently. Many threads may share the same address space. Each thread has its own private attributes: stack, program counter and register context. 1/13/2019 B.Ramamurthy

Threads and Processes 1/13/2019 B.Ramamurthy

Thread Operations Basic Operations associated with a thread are: Spawn : newly created into the ready state Block : waiting for an event Unblock : moved into ready from blocked Finish : exit after normal or abnormal termination. 1/13/2019 B.Ramamurthy

Issues When a thread blocks should the process associated with it blocked? Do we need different types of threads for process context and kernel context? Should a thread be bound to a processor? If so, when? How about daemon threads ? Just like zombie processes? Thread scheduling : user level control? How many concurrent threads? How about thread synchronization? 1/13/2019 B.Ramamurthy

User-level Threads User Level Threads (ULTs) concept is supported by a thread library. All the thread-related operations are supported by the library: creating, destroying, passing messages, scheduling, saving and restoring contexts. An OS may support only ULT… 1/13/2019 B.Ramamurthy

POSIX threads standard There are two main UNIX thread interfaces: IEEE Portable Operating System Interface (POSIX) standard P1003.1c UNIX International (UI) threads standard. Both have the same basic model of threads, though the actual function tend to use different styles. We will use POSIX standards. 1/13/2019 B.Ramamurthy

Thread Control Thread creation (create, run, join, kill) Thread schedule (yield) Thread synchronization (mutex, barrier) Code for execution 1/13/2019 B.Ramamurthy