1 Process Management. 2 Process Process is a program in execution; process execution must progress in sequential fashion A process includes: –program.

Slides:



Advertisements
Similar presentations
©2009 Operačné systémy Procesy. 3.2 ©2009 Operačné systémy Process in Memory.
Advertisements

Abhinav Kamra Computer Science, Columbia University 4.1 Operating System Concepts Silberschatz, Galvin and Gagne  2002 Chapter 4: Processes Process Concept.
Adapted from slides ©2005 Silberschatz, Galvin, and Gagne Lecture 4: Processes.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives Understand Process concept Process scheduling Creating.
Chapter 3: Processes.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
CMPT 300: Operating Systems I Ch 3: Processes Dr. Mohamed Hefeeda
1/30/2004CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Process Concept n An operating system executes a variety of programs: –Batch system – jobs –Time-shared systems – user programs or tasks n Textbook uses.
Chapter 3: Processes. Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
Operating System Concepts
1/26/2007CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Silberschatz and Galvin  Operating System Concepts Module 4: Processes Process Concept Process Scheduling Operation on Processes Cooperating.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operation on Processes.
Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Inter-process Communication Communication in Client-Server.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server Systems.
Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication in Client-Server.
Chapter 3 Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Jan 19, 2005 Chapter 3: Processes Process Concept.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 4 Process Slide 1 Chapter 4 Process.
AE4B33OSS Chapter 3: Processes. 3.2Silberschatz, Galvin and Gagne ©2005AE4B33OSS Chapter 3: Processes Process Concept Process Scheduling Operations on.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Outline n Process Concept n Process.
Chapter 3: Processes (6 th edition chap 4). 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Chapter 3: Processes. 3.2CSCI 380 Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication.
1 11/1/2015 Chapter 4: Processes l Process Concept l Process Scheduling l Operations on Processes l Cooperating Processes l Interprocess Communication.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 2 Processes Processes Topics Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Processes. Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication.
11/13/20151 Processes ICS 240: Operating Systems –William Albritton Information and Computer Sciences Department at Leeward Community College –Original.
CS212: OPERATING SYSTEM Lecture 2: Process 1. Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 3 Operating Systems.
Chapter 3: Process-Concept. Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
3.1 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Overview: Process Concept Process Scheduling Operations on Processes.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Jan 19, 2005 Chapter 3: Processes Process Concept.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Chapter 3: Processes-Concept. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes-Concept Overview Process Scheduling.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Processes. Process Concept Process Scheduling Operations on Processes Interprocess Communication Communication in Client-Server Systems.
Lecture 4: Processes & Threads. Lecture 4 / Page 2AE4B33OSS Silberschatz, Galvin and Gagne ©2005 Contents The concept of Process Process states and life-cycle.
 Process Concept  Process Scheduling  Operations on Processes  Cooperating Processes  Interprocess Communication  Communication in Client-Server.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server.
Chapter 3: Process-Concept. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 3: Process-Concept Process Concept Process Scheduling.
4.1 Operating System Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication.
Process Management.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
XE33OSA Chapter 3: Processes. 3.2XE33OSASilberschatz, Galvin and Gagne ©2005 Chapter 3: Processes Process Concept Process Scheduling Operations on Processes.
Operating System Components) These components reflect the services made available by the O.S. Process Management Memory Management I/O Device Management.
Chapter 3: Process Concept
Operating System Concepts
Process Management Presented By Aditya Gupta Assistant Professor
Processes Overview: Process Concept Process Scheduling
Chapter 3: Process Concept
Applied Operating System Concepts
Chapter 4: Processes Process Concept Process Scheduling
Lecture 2: Processes Part 1
Recap OS manages and arbitrates resources
Operating System Concepts
Presentation transcript:

1 Process Management

2 Process Process is a program in execution; process execution must progress in sequential fashion A process includes: –program counter –Stack (Registers) contains temporary data such a functions parameters, return address and local variables –data section (global Variables)

3 Process Model In this model all the runnable software on the computer, sometimes including the operating system, is organized into a number of sequential processes or simply processes. Conceptually each process has its own virtual CPU, in reality the real CPU switches back and forth from process to process (multiprogramming)

(a)Multiprogramming of four programs. (b) Conceptual model of four independent, sequential processes. (c) Only one program is active at once. The Process Model

5 Difference between Process and Program Program is an algorithm expressed in a suitable notation where as a process is a program in execution Process is an activity of some kind. It has a program, input, output and a state. 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.

Events which cause process creation: System initialization. Execution of a process creation system call by a running process. A user request to create a new process. Initiation of a batch job. Process Creation

7 Process Creation-System initialization When an OS is booted, several processes are created Foreground processes-interact with the user and perform work for them Background processes-not associated with particular users, but instead have specific function (e.g. a background process to accept incoming request for web pages hosted on a machine, waking up when the request comes)

8 Process Creation- by process creation system call A running process may issue system calls to create one or more new processes to help it do the job Useful when the work to be done can be formulated in terms of several related but otherwise independent interacting processes E.g. In Unix when compiling a large program, the make program invokes the C compiler to convert source file to object code and then it invokes the install program to copy the program to its destination, set ownership and permissions etc.

9 Process Creation- User Request, Initialization of a batch process In interactive systems, users can start a program by typing a command In case of batch processing systems, users can submit batch jobs to the system. When OS decides that it has the resources to run another job, it creates a new process and runs the next job from the input queue in it.

10 Process Termination Events which cause process termination: Normal exit (voluntary). Error exit (voluntary). Fatal error (involuntary). Killed by another process (involuntary).

11 Process Termination-Normal Exit If a process has completed it work then it performs a normal exit voluntarily. E.g. When a compiler has compiled the program given to it, the compiler executes a system call to tell the OS that it has finished the compilation

12 Process Termination-Error exit If a process discovers a fatal error it performs a error exit voluntarily E.g. if a user types the command to compile a program and no such file exists, the compiler simply exits

13 Process Termination-fatal error If an error is caused by the process due to a program bug it discovers a fatal error and terminates involuntarily E.g. Executing an illegal instruction, referencing nonexistent memory or dividing by zero

14 Process Termination-Killed by another process If one process executes a system call telling the operating System to kill another process (the killing process must have the authorization to kill the process) In some systems, when a process terminates, either voluntarily or involuntarily, all process it has created will be immediately killed

15 Process Hierarchies Parent creates a child process, child processes can create its own process Unix forms a hierarchy –Unix calls this a "process group” Windows has no concept of process hierarchy –all processes are created equal

A process can be in running, blocked, or ready state. Transitions between these states are as shown. Process States

17 Process States When a process blocks, it does so because logically it can continue, typically because it is waiting for input that is not yet available It may be ready and able to run to be stopped because the OS has decided to allocate the CPU to another process for a while

18 Implementation of processes To implement the process model,the OS maintains a table called the process table (an array of structures), with one entry per process (also called Process control Blocks) This entry contains information about –the process’ state, –its program counter, –stack pointer, –memory allocation, –the status of its open files, –its accounting and scheduling information, –alarms and other signals That must be saved when process switches from running to ready state so that it can be restarted later

The lowest layer of a process-structured operating system handles interrupts and scheduling. Above that layer are sequential processes. Implementation of Processes (1)

20 Implementation of Processes (2)

Some of the fields of a typical process table entry. Implementation of Processes (3)

Skeleton of what the lowest level of the operating system does when an interrupt occurs. Implementation of Processes (4)

23 Process Control Block (PCB) Information associated with each process Process state Program counter CPU registers CPU scheduling information Memory-management information Accounting information I/O status information

24 Process Control Block (PCB)

25 CPU Switch From Process to Process

26 Process Scheduling The objective of multiprogramming is to have some process running at all times to maximize CPU utilization. The objective of time sharing is to switch the CPU among processes so frequently that users can interact with each program while it is running. To meet these objectives, the process scheduler selects an available process from a set of available process, for program execution on the CPU

27 Process Scheduling Queues Job queue – set of all processes in the system Ready queue – set of all processes residing in main memory, ready and waiting to execute, generally stored as a linked list. A ready-queue header contains the pointers to first and last PCB in the list. Each PCB includes a pointer that points to the next PCB in the ready queue Device queues – set of processes waiting for an I/O device. Each device has its own device queue Processes switches among the various queues

28 Ready Queue And Various I/O Device Queues

29 Process Scheduling-Queuing Common representation of process scheduling is queuing diagram. Each rectangular box represents a queue (ready & set of device queues). Circles represent resources that serve the queue and arrow show the flow of processes in the system. A new process is put in a ready queue. It waits there until it is selected for execution or s dispatched Once the process is allocated to CPU and is executing,these events could happen –The process could issue an I/O request and then be placed in an I/O queue –The process could create a new sub process and wait for its termination. – Due to an interrupt the process may be removed form CPU forcefully and put back in ready queue

30 Representation of Process Scheduling

31 Schedulers Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU

32 Schedulers (Cont) Short-term scheduler is invoked very frequently (milliseconds)  (must be fast) Long-term scheduler is invoked very infrequently (seconds, minutes)  (may be slow) The long-term scheduler controls the degree of multiprogramming Processes can be described as either: –I/O-bound process – spends more time doing I/O than computations, many short CPU bursts –CPU-bound process – spends more time doing computations; few very long CPU bursts

33 Addition of Medium Term Scheduling

34 Context Switch When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process via a task known as Context Switch Context of a process represented in the PCB Context-switch time is overhead; the system does no useful work while switching Time dependent on hardware support

35  The term thread is shorthand for "thread of control." A thread is the path taken by a program while running, the steps performed, and the order in which the steps are performed. A thread runs code from its starting location in an ordered, predefined sequence for a given set of inputs.  Like a process, except that some state is shared  Threads have their own registers and stack frames  Threads share memory  Tradeoffs: better performance vs. programming complexity + less protection  Switching to another thread: save registers, find the right stack frame, load registers, run thread  Typically used to service asynchronous events Threads

36 Single and Multithreaded Processes

37 Thread models User threads model, all program threads share the same process thread. The scheduling policy allows only one thread to be actively running in the process at a time. The operating system kernel is only aware of a single task in the process. Kernel threads model, kernel threads are separate tasks that are associated with a process. Uses a pre-emptive scheduling policy in which the operating system decides which thread is eligible to share the processor. One-to-one mapping between program threads and process threads. OS/400 supports a kernel thread model. MxN thread model. Each process has M user threads that share N kernel threads. The user threads are scheduled on top of the kernel threads. The system allocates resources only to the more "expensive" kernel threads.

38 Inter-Process Communication Process executing concurrently in the Operating Systems may be either independent processes or cooperating processes An independent process cannot affect or be affected by the other processes executing in the system (Any process that do not share data with any other process) A Cooperating process will affect or be affected by the other processes executing in the system (Any process that share data with any other process)

39 Reasons for Cooperating processes –Information sharing –Computation speedup –Modularity –Convenience (user may work on same task at the same time) Cooperating processes need inter-process communication (IPC) Two models of IPC –Shared memory –Message passing

40 Communications Models Message Passing Shared Memory

41 Shared Memory Systems Communicating processes must establish a region of shared memory. A shared memory region resides in the address space of the process creating the shared memory segment.Other processes that wish to communicate using this shared memory segment must attach it to their memory space. Normally the OS tries to prevent the processes from accessing other process address space, but this type of IPC requires processes to agree to remove this restriction. They exchange information by reading and writing in this shared area. The form of data and the location must be determined by the processes and are not under OS’s control

42 Interprocess Communication – Message Passing Mechanism for processes to communicate and to synchronize their actions Message system – processes communicate with each other without resorting to shared variables IPC facility provides two operations: –send(message) – message size fixed or variable –receive(message) If P and Q wish to communicate, they need to: –establish a communication link between them –exchange messages via send/receive Implementation of communication link –physical (e.g., shared memory, hardware bus) –logical (e.g., logical properties)

43 Direct Communication Processes must name each other explicitly: –send (P, message) – send a message to process P –receive(Q, message) – receive a message from process Q Properties of communication link –Links are established automatically –A link is associated with exactly one pair of communicating processes –Between each pair there exists exactly one link –The link may be unidirectional, but is usually bi- directional

44 Indirect Communication Messages are directed and received from mailboxes (also referred to as ports) –Each mailbox has a unique id –Processes can communicate only if they share a mailbox Properties of communication link –Link established only if processes share a common mailbox –A link may be associated with many processes –Each pair of processes may share several communication links –Link may be unidirectional or bi-directional

45 Indirect Communication Operations –create a new mailbox –send and receive messages through mailbox –destroy a mailbox Primitives are defined as: send(A, message) – send a message to mailbox A receive(A, message) – receive a message from mailbox A

46 Indirect Communication Mailbox sharing –P 1, P 2, and P 3 share mailbox A –P 1, sends; P 2 and P 3 receive –Who gets the message? Solutions –Allow a link to be associated with at most two processes –Allow only one process at a time to execute a receive operation –Allow the system to select arbitrarily the receiver. Sender is notified who the receiver was.

47 Synchronization Message passing may be either blocking or non- blocking Blocking is considered synchronous –Blocking send has the sender block until the message is received –Blocking receive has the receiver block until a message is available Non-blocking is considered asynchronous –Non-blocking send has the sender send the message and continue –Non-blocking receive has the receiver receive a valid message or null

48 Buffering Queue of messages attached to the link; implemented in one of three ways 1.Zero capacity – 0 messages Sender must wait for receiver (rendezvous) 2.Bounded capacity – finite length of n messages Sender must wait if link full 3.Unbounded capacity – infinite length Sender never waits