1 Processes and Threads Creation and Termination States Usage Implementations.

Slides:



Advertisements
Similar presentations
Threads Chapter 4 Threads are a subdivision of processes
Advertisements

Process Description and Control
OPERATING SYSTEMS Lecturer: Szabolcs Mikulas Office: B38B
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc
Chapter 3 Memory Management
Memory Management.
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Processes Management.
25 seconds left…...
We will resume in: 25 Minutes.
Pertemuan 13 Threads Matakuliah: H0483 / Network Programming Tahun: 2005 Versi: 1.0.
Operating Systems COMP 4850/CISG 5550 Processes Introduction to Threads Dr. James Money.
1 Created by Another Process Reason: modeling concurrent sub-tasks Fetch large amount data from network and process them Two sub-tasks: fetching  processing.
Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
1 Threads CSCE 351: Operating System Kernels Witawas Srisa-an Chapter 4-5.
Threads Section 2.2. Introduction to threads A thread (of execution) is a light-weight process –Threads reside within processes. –They share one address.
Thursday, June 08, 2006 The number of UNIX installations has grown to 10, with more expected. The UNIX Programmer's Manual, 2nd Edition, June, 1972.
Page 1 Processes and Threads Chapter 2. Page 2 Processes The Process Model Multiprogramming of four programs Conceptual model of 4 independent, sequential.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
1 CS 333 Introduction to Operating Systems Class 2 – OS-Related Hardware & Software The Process Concept Jonathan Walpole Computer Science Portland State.
1 What is a Process ? The activity of program execution. Also called a task or job Has associated with it: Code Data Resources A State An executing set.
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
CSCE 351: Operating System Kernels
3.5 Interprocess Communication
Chapter 2 Processes and Threads Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
ThreadsThreads operating systems. ThreadsThreads A Thread, or thread of execution, is the sequence of instructions being executed. A process may have.
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION Third Edition ANDREW S. TANENBAUM ALBERT S. WOODHULL Yan hao (Wilson) Wu University of the Western.
Processes Part I Processes & Threads* *Referred to slides by Dr. Sanjeev Setia at George Mason University Chapter 3.
1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Processes and Threads.
1 Process States (1) Possible process states –running –blocked –ready Transitions between states shown.
10/16/ Realizing Concurrency using the thread model B. Ramamurthy.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 2 Processes and Threads Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Operating Systems Processes 1.
Joonwon Lee Process and Address Space.
ITFN 3601 Introduction to Operating Systems Lecture 3 Processes, Threads & Scheduling Intro.
CSC 322 Operating Systems Concepts Lecture - 7: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Cs431-cotter1 Processes and Threads Tanenbaum 2.1, 2.2 Crowley Chapters 3, 5 Stallings Chapter 3, 4 Silberschaz & Galvin 3, 4.
Shahriar Pirnia Operating system سيستم عامل.
Processes and Threads MICROSOFT.  Process  Process Model  Process Creation  Process Termination  Process States  Implementation of Processes  Thread.
2.1 Processes  process = abstraction of a running program  multiprogramming = CPU switches from running program to running program  pseudoparallelism.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-2: Threads Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
7/9/ Realizing Concurrency using Posix Threads (pthreads) B. Ramamurthy.
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 2 Processes and Threads Today 2.1 Processes 2.2 Threads
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Realizing Concurrency using Posix Threads (pthreads)
Realizing Concurrency using the thread model
Implementing Threads in User Space
Module 2.1 COP4600 – Operating Systems Richard Newman
Process Description and Control
Threads and Concurrency
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Jonathan Walpole Computer Science Portland State University
Prof. Leonardo Mostarda University of Camerino
Process Description and Control
Operating Systems Threads 1.
Realizing Concurrency using Posix Threads (pthreads)
Realizing Concurrency using the thread model
Realizing Concurrency using Posix Threads (pthreads)
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
CS510 Operating System Foundations
Thread Model for Work Unit
Process Management -Compiled for CSIT
What is a Thread? A thread is similar to a process, but it typically consists of just the flow of control. Multiple threads use the address space of a.
Threads CSE 2431: Introduction to Operating Systems
Presentation transcript:

1 Processes and Threads Creation and Termination States Usage Implementations

2 Processes Program in execution (cf. recipe vs. cooking) Multiprogramming - pseudo-parallelism (vs. true hardware parallelism of multiprocessor systems)

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

4 Process Creation Principal events that cause process creation 1.System initialization (foreground a daemon processes) Execution of a process creation system call (data from network) 1.User request to create a new process 2.Initiation of a batch job UNIX: fork system call (+ execve) Windows: CreateProcess function call

5 Process Termination Conditions which terminate processes 1.Normal exit (voluntary) - (exit, ExitProcess) 2.Error exit (voluntary) 3.Fatal error (involuntary), e.g. program bug 4.Killed by another process (involuntary) - kill, TerminateProcess

6 Process Hierarchies Parent creates a child process, child processes can create its own process Forms a hierarchy –UNIX calls this a "process group –init Windows has no concept of process hierarchy –all processes are created equal

7 Process States (1) Possible process states –running –blocked –ready Transitions between states shown

8 Process States (2) Lowest layer of process-structured OS –handles interrupts, scheduling Above that layer are sequential processes

9 Implementation of Processes (1) Fields of a process table entry

10 Implementation of Processes (2) Skeleton of what lowest level of OS does when an interrupt occurs

11 Threads Process = resource grouping (code, data, open files, etc.) + execution (program counter, registers, stack) Multithreading: multiple execution takes place in the same process environment co-operation by sharing resources (address space, open files, etc.)

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

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

14 The Thread Model (3) Each thread has its own stack to keep track execution history (called procedures)

15 Advantages Pseudo-parallelism with shared address space and data Easier to create and destroy than processes Better performance for I/O bound applications

16 Thread Usage (1) A word processor with three threads Writing a book: interactive and background threads sharing the same file

17 Thread Usage (2) A multithreaded Web server

18 Thread Usage (3) Rough outline of code for previous slide (a) Dispatcher thread (b) Worker thread

19 Thread Usage (4) Three ways to construct a server

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

21 (Dis)advantages +:no specific OS support needed faster than kernel instructions process-specific scheduling algorithms -:blocking system calls ( select ) page faults

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

23 (Dis)advantages +:handling blocking and page faults -:more costly (but recycling threads)

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

25 Scheduler Activations Goal: – mimic functionality of kernel threads –gain performance of user space threads Avoids unnecessary user/kernel transitions Kernel assigns virtual processors to each process –lets runtime system allocate threads to processors, upcall Problem: Fundamental reliance on kernel (lower layer) calling procedures in user space (higher layer)

26 Pop-Up Threads Creation of a new thread when message arrives (a) before message arrives (b) after message arrives (quick)

27 Making Single-Threaded Code Multithreaded (1) Conflicts between threads over the use of a global variable

28 Making Single-Threaded Code Multithreaded (2) Threads can have private global variables. But non-reentrant library procedures.