Processes Part I Processes & Threads* *Referred to slides by Dr. Sanjeev Setia at George Mason University Chapter 3.

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.
OPERATING SYSTEMS Threads
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Multithreaded Programming.
Threads. Objectives To introduce the notion of a thread — a fundamental unit of CPU utilization that forms the basis of multithreaded computer systems.
Chapter 5 Threads os5.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 5: Threads 9/29/03+ Overview Benefits User and Kernel Threads Multithreading.
Threads Clients Servers Code Migration Software Agents Summary
Threads - Definition - Advantages using Threads - User and Kernel Threads - Multithreading Models - Java and Solaris Threads - Examples - Definition -
CS238 Lecture 5 Threads Dr. Alan R. Davis. Threads Definitions Benefits User and Kernel Threads Multithreading Models Solaris 2 Threads Java Threads.
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
Based on Silberschatz, Galvin and Gagne  2009 Threads Definition and motivation Multithreading Models Threading Issues Examples.
3.5 Interprocess Communication
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Threads. Processes and Threads  Two characteristics of “processes” as considered so far: Unit of resource allocation Unit of dispatch  Characteristics.
Process Concept An operating system executes a variety of programs
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Chapter 4: Threads READ 4.1 & 4.2 NOT RESPONSIBLE FOR 4.3 &
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.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 4: Threads Overview Multithreading Models Threading Issues.
ThreadsThreads operating systems. ThreadsThreads A Thread, or thread of execution, is the sequence of instructions being executed. A process may have.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
Multithreading Allows application to split itself into multiple “threads” of execution (“threads of execution”). OS support for creating threads, terminating.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Threads, Thread management & Resource Management.
CHAPTER 5: THREADS ( 线程 ) Overview Overview Multithreading Models (多线程模型) Multithreading Models (多线程模型) Thread Implementation Issues (线程实现事项) Thread Implementation.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Multithreading Models Threading Issues Pthreads Solaris 2 Threads.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 4: Threads Overview Multithreading Models Threading Issues.
Overview Multithreading Models Threading Issues Pthreads Solaris 2 Threads Windows 2000 Threads Linux Threads Java Threads.
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 4: Threads Modified from the slides of the text book. TY, Sept 2010.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Department of Computer Science and Software Engineering
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
1 OS Review Processes and Threads Chi Zhang
Operating Systems Unit 2: – Process Context switch Interrupt Interprocess communication – Thread Thread models Operating Systems.
Operating System Concepts
1 Threads, SMP, and Microkernels Chapter 4. 2 Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-
Lecturer 3: Processes multithreaded Operating System Concepts Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess.
Processes Chapter 3. Processes in Distributed Systems Processes and threads –Introduction to threads –Distinction between threads and processes Threads.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
OPERATING SYSTEM CONCEPT AND PRACTISE
Chapter 2 Processes and Threads Today 2.1 Processes 2.2 Threads
Chapter 5: Threads Overview Multithreading Models Threading Issues
Chapter 5: Threads Overview Multithreading Models Threading Issues
Chapter 5: Threads Overview Multithreading Models Threading Issues
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 4 Threads.
Threads & multithreading
Operating Systems Processes and Threads.
Chapter 4: Threads.
Chapter 5: Threads Overview Multithreading Models Threading Issues
Chapter 4: Threads.
CHAPTER 4:THreads Bashair Al-harthi OPERATING SYSTEM
Chapter 5: Threads Overview Multithreading Models Threading Issues
Chapter 4: Threads.
Presentation transcript:

Processes Part I Processes & Threads* *Referred to slides by Dr. Sanjeev Setia at George Mason University Chapter 3

Process A program in execution An instance of a program running on a computer The entity that can be assigned to and executed on a processor A unit of activity characterized by –the execution of a sequence of instructions –a current state –an associated set of system resources

Address Space PCB Process in Memory

Multiprogramming The interleaved execution of two or more computer programs by a single processor An important technique that –enables a time-sharing system –allows the OS to overlap I/O and computation, creating an efficient system

Processes The Process Model Multiprogramming of four programs Conceptual model of 4 independent, sequential processes Only one program active at any instant 5

Multiprogramming

Cooperating Processes (I) Sequential programs consist of a single process Concurrent applications consist of multiple cooperating processes that execute concurrently Advantages –Can exploit multiple CPUs (hardware concurrency) for speeding up application –Application can benefit from software concurrency, e.g., web servers, window systems

Cooperating Processes (II) Cooperating processes need to share information Since each process has its own address space, OS mechanisms are needed to let process exchange information Two paradigms for cooperating processes –Shared Memory OS enables two independent processes to have a shared memory segment in their address spaces –Message-passing OS provides mechanisms for processes to send and receive messages

Threads: Motivation Process created and managed by the OS kernel –Process creation expensive, e.g., fork system call –Context switching expensive –IPC requires kernel intervention expensive –Cooperating processes – no need for memory protection, i.e., separate address spaces

10 Threads The Thread Model (1) (a) Three processes each with one thread (b) One process with three threads

11 The Thread Model (2) Items shared by all threads in a process Items private to each thread

12 The Thread Model (3) Each thread has its own stack

13 Thread Usage (1) A word processor with three threads

14 Thread Usage (2) A multithreaded Web server

Thread Implementation - Packages Threads are provided as a package, including operations to create, destroy, and synchronize them A package can be implemented as: –User-level threads –Kernel threads

17 Implementing Threads in User Space A user-level threads package

User-Level Threads Thread management done by user-level threads library Examples –POSIX Pthreads –Mach C-threads –Solaris threads –Java threads

User-Level Threads Thread library entirely executed in user mode Cheap to manage threads –Create: setup a stack –Destroy: free up memory Context switch requires few instructions –Just save CPU registers –Done based on program logic A blocking system call blocks all peer threads

Kernel-Level Threads Kernel is aware of and schedules threads A blocking system call, will not block all peer threads Expensive to manage threads Expensive context switch Kernel Intervention

21 Implementing Threads in the Kernel A threads package managed by the kernel

Kernel Threads Supported by the Kernel Examples: newer versions of –Windows –UNIX –Linux

Linux Threads Linux refers to them as tasks rather than threads. Thread creation is done through clone() system call. Unlike fork(), clone() allows a child task to share the address space of the parent task (process)

Pthreads A POSIX standard (IEEE c) API for thread creation and synchronization. API specifies behavior of the thread library, implementation is up to development of the library. POSIX Pthreads - may be provided as either a user or kernel library, as an extension to the POSIX standard. Common in UNIX operating systems.

25 Hybrid Implementations Multiplexing user-level threads onto kernel- level threads

Solaris Threads (LWP)

LWP Advantages Cheap user-level thread management A blocking system call will not suspend the whole process LWPs are transparent to the application LWPs can be easily mapped to different CPUs