Processes and Threads MICROSOFT.  Process  Process Model  Process Creation  Process Termination  Process States  Implementation of Processes  Thread.

Slides:



Advertisements
Similar presentations
1 Processes and Threads Creation and Termination States Usage Implementations.
Advertisements

Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
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.
Chap 4 Multithreaded Programming. Thread A thread is a basic unit of CPU utilization It comprises a thread ID, a program counter, a register set and a.
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.
Computer Systems/Operating Systems - Class 8
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 Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
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.
CSCE 351: Operating System Kernels
Chapter 2 Processes and Threads Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
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.
Phones OFF Please Processes Parminder Singh Kang Home:
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION Third Edition ANDREW S. TANENBAUM ALBERT S. WOODHULL Yan hao (Wilson) Wu University of the Western.
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 Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Processes and 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.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Threads, Thread management & Resource Management.
Chapter 3 Process Description and Control
Processes and Threads Processes have two characteristics: – Resource ownership - process includes a virtual address space to hold the process image – Scheduling/execution.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 2 Processes and Threads Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
 2004 Deitel & Associates, Inc. All rights reserved. 1 Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Threads G.Anuradha (Reference : William Stallings)
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
Operating Systems Processes 1.
Silberschatz, Galvin and Gagne  Operating System Concepts Process Concept An operating system executes a variety of programs:  Batch system.
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.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
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.
OPERATING SYSTEM LESSON 5 THREADS. 2 The process model is based on two independent concepts: resource grouping and execution. A process is the way to.
Saurav Karmakar. Chapter 4: Threads  Overview  Multithreading Models  Thread Libraries  Threading Issues  Operating System Examples  Windows XP.
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.
1 Threads, SMP, and Microkernels Chapter 4. 2 Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
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 – Thread Concepts
Process Management Process Concept Why only the global variables?
Chapter 4 – Thread Concepts
Chapter 2 Processes and Threads Today 2.1 Processes 2.2 Threads
Process Management Presented By Aditya Gupta Assistant Professor
Example questions… Can a shell kill itself? Can a shell within a shell kill the parent shell? What happens to background processes when you exit from.
Threads & multithreading
MODERN OPERATING SYSTEMS Third Edition ANDREW S
2.1 Processes process = abstraction of a running program
Process Description and Control
Process Description and Control
Threads and Concurrency
Threads Chapter 4.
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Process Description and Control
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
CS510 Operating System Foundations
Process Management -Compiled for CSIT
Process Management -Compiled for CSIT
Threads CSE 2431: Introduction to Operating Systems
Presentation transcript:

Processes and Threads MICROSOFT

 Process  Process Model  Process Creation  Process Termination  Process States  Implementation of Processes  Thread  Thread Model  Implementation of Threads in user space  Implementation of Threads in kernel Space  Pop-Up Threads  Making Single Threaded code multithreaded Agenda

 Process is an instance of program that is being executed.  It contains the program code and its current activity.  Depending on the Operating System(OS), a process may be made up of multiple threads of execution that execute instructions concurrently.  Parallelism What is a Process?

 In this model, all the runnable software on the computer, sometimes including the operating system, is organized into a number of sequential processes.  A process is just an executing program, including the current values of the program counter, registers, and variables.  CPU switches back and forth from process to process, but to understand the system, it is much easier to think about a collection of processes running parallel.  The rapid switching back and forth is called multiprogramming. Process Model:-

Process is an activity of some kind. Process ProgramInput OutputState A single processor may be shared among several processes, with some scheduling algorithm being used to determine when to stop work on one process and service a different one.

Four Principle Events that cause processes to be created: 1. System initialization. 2. Execution of a process creation system call by a running process. 3. A user request to create a new process. 4. Initiation of a batch job. Process Creation:-

Processes that stay in the background to handle some activity such as , Web pages, news, printing, and so on are called daemons. Foreground Processes Background Processes Processes that interact with users Not associated with particular user, they have some specific function

In Unix fork This call creates an exact clone of the calling process. UNIX:- System Call: System call tells the operating system to create a new process and indicates, directly or indirectly, which program to run in it. Usually, the child process then executes execve or a similar system call to change its memory image and run a new program. WINDOWS: CreateProcess Win32 function call CreationLoading

CreateProcess This call has 10 parameters which include:- Program to be executed The command line parameters to feed that program Various security attributes Bits that control whether open files are inherited A specification of the window to be created for the process (if any) A pointer to a structure in which information about the newly created process is returned to the caller. In both UNIX and Windows, after a process is created, both the parent and child have their own distinct address spaces.

1.Normal exit (voluntary). 2.Error exit (voluntary). 3.Fatal error (involuntary). 4.Killed by another process (involuntary). Process Termination:- Normal Exit: Exit – Unix ExitProcess – Windows Screen-oriented programs also support voluntary termination Fatal Error: cc foo.c Screen-oriented interactive processes generally do not exit when given bad parameters. Instead they pop up a dialog box and ask the user to try again.

 When a process creates another process, the parent process and child process continue to be associated in certain ways.  The child process can itself create more processes, forming a process hierarchy.  Windows does not have any concept of a process hierarchy. All processes are equal.  The only place where there is something like a process hierarchy is that when a process is created, the parent is given a special token (called a handle) that it can use to control the child. Process Hierarchies:-

new Enter Ready Admit Running Dispatch Time-Up Blocked I/O Request I/O Completion (wake up) Halted Terminate Halt/Kill Process States and it’s Transitions:-

What is a Thread? A thread is a single sequence stream within a process. Threads have some of the properties of processes, they sometimes called as, Lightweight processes. multiple executions of streams THREADS:

 The process model is based on two independent concepts: resource grouping and execution. Sometimes it is useful to separate them; this is where threads come in.  The other concept a process has is a thread of execution, usually shortened to just thread.  The thread has a program counter that keeps track of which instruction to execute next.  Registers  Stack Thread Model:-

Per process itemsPer thread items Address space Global variables Open files Child processes Pending alarms Signals and signal handlers Accounting information Program counter Registers Stack State The first column lists some items shared by all threads in a process. The second one lists some items private to each thread. In addition to sharing an address space, all the threads share the same set of open files, child processes, alarms, and signals, etc.

Each thread has its own stack 2. Thread_exit 3. Thread_wait 4. Thread_yield 1. Thread_Create

Processes Vs Threads: Similarities  Like processes, threads share same CPU and only one thread (active) running at a time.  Like processes, threads within a processes execute sequentially.  Like processes, threads can create children.  If a thread is blocked, another thread can run. Differences  Unlike process, threads are not independent of one another.  All threads can access every address in the task.  Thread are designed to assist one another.  Note that processes might or might not assist one another because processes may originate from different users.

There are two main ways to implement a threads package: 1. User Space 2. Kernel Space Implementing Threads in User Space and Kernel Space:

Hybrid Implementations:- -- Various ways have been investigated to try to combine the advantages of user-level threads with kernel-level threads. One way is use kernel-level threads and then multiplex user-level threads onto some or all of the kernel threads Multiplexing user-level threads onto kernel-level threads.

Pop-Up Threads Creation of new thread when a message arrives. (a)Before the message arrives. (b) After the message arrives.

Making Single-Threaded Code Multithreaded: Code of a thread normally consists of multiple procedures just like a process. 1. Local Variables 2. Global Variables 3. Procedure Parameters Errno is a variable maintained by UNIX When a process/thread makes a system call that fails, The error code is put in to “Errno”.

Threads having private global variables:

First Call: create_global("bufptr"); Two calls are needed to access global variables: one for writing them and the other for reading them. For writing, set_global("bufptr", &buf); It stores the value of a pointer in the storage location previously created by the call to create_global. To read global Variable, bufptr = read_global ("bufptr"); It returns the address stored in the global variable, so its data can be accessed.