Operating Systems Unit 2: – Process Context switch Interrupt Interprocess communication – Thread Thread models Operating Systems.

Slides:



Advertisements
Similar presentations
Threads, SMP, and Microkernels
Advertisements

3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
 2004 Deitel & Associates, Inc. All rights reserved. 1 Chapter 3 – Process Concepts Outline 3.1 Introduction 3.1.1Definition of Process 3.2Process States:
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.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 6: Threads Chapter 4.
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.
Modified from Silberschatz, Galvin and Gagne ©2009 Lecture 7 Chapter 4: Threads (cont)
Chapter 4: Multithreaded Programming
Chapter 5 Processes and Threads Copyright © 2008.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
3.5 Interprocess Communication
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Threads CSCI 444/544 Operating Systems Fall 2008.
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for Threads.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
4.7.1 Thread Signal Delivery Two types of signals –Synchronous: Occur as a direct result of program execution Should be delivered to currently executing.
Process Concept An operating system executes a variety of programs
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
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 &
Threads Chapter 4. Modern Process & Thread –Process is an infrastructure in which execution takes place  (address space + resources) –Thread is a program.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Multithreaded Programming.
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.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads.
Chapter 4: Threads. From Processes to Threads 4.3 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Threads.
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads.
Silberschatz, Galvin and Gagne ©2011Operating System Concepts Essentials – 8 th Edition Chapter 4: Threads.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
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.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
 2004 Deitel & Associates, Inc. All rights reserved. 1 Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for.
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)
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 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.
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: Multithreaded Programming. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts What is Thread “Thread is a part of a program.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: 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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
Processes & Threads Introduction to Operating Systems: Module 5.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Saurav Karmakar. Chapter 4: Threads  Overview  Multithreading Models  Thread Libraries  Threading Issues  Operating System Examples  Windows XP.
Operating System Concepts
Chapter 4: Threads 羅習五. Chapter 4: Threads Motivation and Overview Multithreading Models Threading Issues Examples – Pthreads – Windows XP Threads – Linux.
Threads, SMP, and Microkernels Chapter 4. Processes and Threads Operating systems use processes for two purposes - Resource allocation and resource ownership.
CISC2200 Threads Fall 09. Process  We learn the concept of process  A program in execution  A process owns some resources  A process executes a program.
Lecturer 3: Processes multithreaded Operating System Concepts Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Chapter 4 – Thread Concepts
Chapter 4 – Thread Concepts
Chapter 3 – Process Concepts
Process Management Presented By Aditya Gupta Assistant Professor
Threads and Cooperation
Threads, SMP, and Microkernels
Lecture 4- Threads, SMP, and Microkernels
Presentation transcript:

Operating Systems Unit 2: – Process Context switch Interrupt Interprocess communication – Thread Thread models Operating Systems

COP Operating Systems2 Definition of Process Set of steps Performance of a task A program in execution

COP Operating Systems3 Definition of Process Process is –Identifiable Entity with properties Text region –Stores the code that the processor executes Data region –Stores variables and dynamically allocated memory Stack region –Stores instructions and local variables for active procedure calls

COP Operating Systems4 Process State Transition Diagram begin end

COP Operating Systems5 … with Suspend and Resume

COP Operating Systems6 Process Management OS functionality: –Create process –Dispatch process –Block/wakeup process –Suspend/resume process –Terminate process Also: –Change process attributes –Enable Interprocess communication

COP Operating Systems7 Process Control Blocks Execution context

COP Operating Systems8 Context Switch stop a running process and start a ready process –Save execution context of running process –Load ready process’s execution context

COP Operating Systems9 Context Switch

COP Operating Systems10 Context Switch Switch must be transparent to process Effort for switch must be minimized –hardware support: Special PCB register to help save/restore Processor is given PCB and perform switch without software intervention

COP Operating Systems11 Interrupt Get attention of processor –enable reaction to signals from hardware –may be initiated by a running process: trap E.g. dividing by zero or referencing protected memory –may be caused by external event Asynchronous with the operation of the process E.g., a keyboard key is pressed, or mouse is moved Alternative: polling

COP Operating Systems12 Interrupt Processing 1.Processor is running a process 2.Interrupt occurs: current instruction is completed 3.Processor determines nature of interrupt 4.Process executes context switch to interrupt handler 5.Interrupt handler executes to completion 6.Next ready process is dispatched

COP Operating Systems13 Interrupt Processing

COP Operating Systems14 Interrupt Classes Interrupts are system specific IA-32 Pentium architecture: Interrupts –Hardware: from devices external to a processor –Software: to enable system calls Exceptions –error has occurred: hardware or software instruction –Terms: fault, trap or abort

COP Operating Systems15 IA32 Hardware Interrupt Classes

COP Operating Systems16 IA32 Exception Classes

COP Operating Systems17 Interprocess Communication Process to process communication –Signal –Message

COP Operating Systems18 Signals Software interrupts –Limited data exchange –Processes may catch, ignore or mask a signal Catch: run specific function on signal Ignore: let OS run default function Mask: prevent signal from occurring

COP Operating Systems19 Message Passing Send and receive functionality Issues: –One directional 1 sender, n receiver(s) –Blocking or non –Implementation: pipe or memory mapping –Security Link reliability Partner authentication

COP Operating Systems20 ? Process is useful concept –to structure operating system –Also: for any complex software Thread concept –Introduces two-level process concept

COP Operating Systems21 Motivation for Threads Threads have become prominent in: –Software design More naturally expresses inherently parallel tasks –Performance Scales better to multiprocessor systems –Cooperation Shared address space incurs less overhead than IPC

COP Operating Systems22 Thread definition Lightweight process (LWP) Thread of instructions or thread of control –Shares address space and other global information with its process –Registers, stack, signal masks and other thread-specific data are local to each thread

COP Operating Systems23 Thread vs. Process

COP Operating Systems24 Thread State Transition Diagram

COP Operating Systems25 Thread Operations Thread and process share common operations Thread specific operations: –Cancel Signals thread to terminate: thread can mask the cancellation signal –Join Thread joins another thread: allows a thread to sleep until joined thread ends

COP Operating Systems26 Threading Models User-level threads Kernel-level threads Combination of user- and kernel-level threads

COP Operating Systems27 User-level Threads Threading operations occur in user space Threads are created by runtime libraries Many-to-one mapping: –User sees multiple threads –OS sees one process

COP Operating Systems28 User-level Threads

COP Operating Systems29 User-level Threads Many-to-one thread mapping –Advantage: User-level scheduling performance tuning avoids OS context switch more portable –Disadvantage: one process for OS All threads in process will block as a whole Cannot be scheduled on multiple processors

COP Operating Systems30 Kernel-level Threads Each thread has own execution one-to-one mapping: –User and OS see multiple threads

COP Operating Systems31 Kernel-level Threads

COP Operating Systems32 Kernel-level Threads one-to-one thread mapping –Advantage Threads can run concurrently on multi processors: increased scalability and interactivity –Disadvantages: context switching overhead reduced portability

COP Operating Systems33 Combining User- and Kernel-level Threads m-to-n thread mapping:

COP Operating Systems34 Combining User- and Kernel-level Threads Thread pool –Set of persistent worker kernel threads –Improves performance in environments where threads are frequently created and destroyed –Each new thread is executed by a worker thread

COP Operating Systems35 Combining User- and Kernel-level Threads Scheduler activation –Meant to address limitations of user-level threads Kernel thread block, blocks all user threads Multiple user threads in kernel thread cannot execute concurrently on multi processor –Upcall: OS calls a user-level threading library that determines if any of its threads need rescheduling

COP Operating Systems36 Thread Implementation Considerations Signal delivery –Synchronous: Occur as a direct result of program execution Should be delivered to currently executing thread –Asynchronous Occur due to an event typically unrelated to the current instruction Threading library must determine each signal’s recipient so that asynchronous signals are delivered properly

COP Operating Systems37 Thread Signal Delivery

COP Operating Systems38 Example: UNIX Process

COP Operating Systems39 Example: Unix threads POSIX Pthreads: –User level thread library Linux threads: –Task: process and thread –Fork vs. Clone system call specify which resources to share with the child thread

COP Operating Systems40 Agenda for next week: Chapter 5 & 6 –Concurrency Issues Read ahead !