1 11/1/2015 Chapter 4: Processes l Process Concept l Process Scheduling l Operations on Processes l Cooperating Processes l Interprocess Communication.

Slides:



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

Dr. Kalpakis CMSC 421, Operating Systems. Fall Processes.
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.
Chapter 3 Processes.
Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Silberschatz, Galvin and Gagne ©2007 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.
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.
Chapter 3: Process-Concept
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.
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.
Chap 3 Processes-Concept. Process Concept Process – a program in execution; process execution must progress in sequential fashion A process includes:
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 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 Chapter 3: Processes Process Concept Process Scheduling Operations.
4.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 4: Processes 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.
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 ©2009 Operating System Concepts – 8 th Edition Chapter 3: Processes Process Concept Process Scheduling.
3.1 Silberschatz, Galvin and Gagne ©2009Operating System Concepts with Java – 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 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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Processes. Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication.
CS212: OPERATING SYSTEM Lecture 2: Process 1. Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
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.
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 3: Process Concept.
3.1 Silberschatz, Galvin and Gagne ©2009Operating System Concepts with Java – 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.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
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.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Jan 19, 2005 Chapter 3: Processes Process Concept.
Chapter 3: Processes-Concept. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes-Concept Overview Process Scheduling.
Processes. Process Concept Process Scheduling Operations on Processes Interprocess Communication Communication in Client-Server Systems.
 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 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.
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.
Chapter 3: Processes.
Topic 3 (Textbook - Chapter 3) Processes
Chapter 4: Processes Process Concept Process Scheduling
Processes Overview: Process Concept Process Scheduling
Chapter 3: Process Concept
Chapter 4: Processes Process Concept Process Scheduling
Operating System Concepts
Processes August 10, 2019 OS:Processes.
Presentation transcript:

1 11/1/2015 Chapter 4: Processes l Process Concept l Process Scheduling l Operations on Processes l Cooperating Processes l Interprocess Communication l Communication in Client-Server Systems

2 11/1/2015 Process Concept l An operating system executes a variety of programs: Batch system – jobs Time-shared systems – user programs or tasks l Textbook uses the terms job and process almost interchangeably. Process – a program in execution; process execution must progress in sequential fashion. l A process includes: n program counter n stack n data section

3 11/1/2015 Process State l As a process executes, it changes state n new: The process is being created. n running: Instructions are being executed. n waiting: The process is waiting for some event to occur. n ready: The process is waiting to be assigned to a process. n terminated: The process has finished execution.

4 11/1/2015 Diagram of Process State

5 11/1/2015 Process Control Block (PCB) Information associated with each process. l Process state l Program counter l CPU registers l CPU scheduling information l Memory-management information l Accounting information l I/O status information

6 11/1/2015 Process Control Block (PCB)

7 11/1/2015 CPU Switch From Process to Process

8 11/1/2015 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. Device queues – set of processes waiting for an I/O device. l Process migration between the various queues.

9 11/1/2015 Ready Queue And Various I/O Device Queues

10 11/1/2015 Representation of Process Scheduling

11 11/1/2015 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.

12 11/1/2015 Addition of Medium Term Scheduling

13 11/1/2015 Schedulers (Cont.) l Short-term scheduler is invoked very frequently (milliseconds)  (must be fast). l Long-term scheduler is invoked very infrequently (seconds, minutes)  (may be slow). l The long-term scheduler controls the degree of multiprogramming. l 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.

14 11/1/2015 Context Switch l 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. l Context-switch time is overhead; the system does no useful work while switching. l Time dependent on hardware support.

15 11/1/2015 Process Creation l Parent process create children processes, which, in turn create other processes, forming a tree of processes. l Resource sharing n Parent and children share all resources. Children share subset of parent ’ s resources. n Parent and child share no resources. l Execution n Parent and children execute concurrently. n Parent waits until children terminate.

16 11/1/2015 Process Creation (Cont.) l Address space n Child duplicate of parent. n Child has a program loaded into it. l UNIX examples n fork system call creates new process exec system call used after a fork to replace the process ’ memory space with a new program.

17 11/1/2015 Processes Tree on a UNIX System

18 11/1/2015 Process Termination l Process executes last statement and asks the operating system to decide it (exit). n Output data from child to parent (via wait). Process ’ resources are deallocated by operating system. l Parent may terminate execution of children processes (abort). n Child has exceeded allocated resources. n Task assigned to child is no longer required. n Parent is exiting. u Operating system does not allow child to continue if its parent terminates. u Cascading termination.

19 11/1/2015 Cooperating Processes l Independent process cannot affect or be affected by the execution of another process. l Cooperating process can affect or be affected by the execution of another process l Advantages of process cooperation n Information sharing n Computation speed-up n Modularity n Convenience

20 11/1/2015 Producer-Consumer Problem l Paradigm for cooperating processes, producer process produces information that is consumed by a consumer process. n unbounded-buffer places no practical limit on the size of the buffer. n bounded-buffer assumes that there is a fixed buffer size.

21 11/1/2015 Bounded-Buffer – Shared-Memory Solution l Shared data #define BUFFER_SIZE 10 Typedef struct {... } item; item buffer[BUFFER_SIZE]; int in = 0; int out = 0; l Solution is correct, but can only use BUFFER_SIZE- 1 elements

22 11/1/2015 Bounded-Buffer – Producer Process item nextProduced; while (1) { while (((in + 1) % BUFFER_SIZE) == out) ; /* do nothing */ buffer[in] = nextProduced; in = (in + 1) % BUFFER_SIZE; }

23 11/1/2015 Bounded-Buffer – Consumer Process item nextConsumed; while (1) { while (in == out) ; /* do nothing */ nextConsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; }

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

25 11/1/2015 Implementation Questions l How are links established? l Can a link be associated with more than two processes? l How many links can there be between every pair of communicating processes? l What is the capacity of a link? l Is the size of a message that the link can accommodate fixed or variable? l Is a link unidirectional or bi-directional?

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

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

28 11/1/2015 Indirect Communication l Operations n create a new mailbox n send and receive messages through mailbox n destroy a mailbox l Primitives are defined as: send(A, message) – send a message to mailbox A receive(A, message) – receive a message from mailbox A

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

30 11/1/2015 Synchronization l Message passing may be either blocking or non-blocking. l Blocking is considered synchronous l Non-blocking is considered asynchronous l send and receive primitives may be either blocking or non- blocking.

31 11/1/2015 Buffering l 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.

32 11/1/2015 Client-Server Communication l Sockets l Remote Procedure Calls l Remote Method Invocation (Java)

33 11/1/2015 Sockets l A socket is defined as an endpoint for communication. l Concatenation of IP address and port l The socket :1625 refers to port 1625 on host l Communication consists between a pair of sockets.

34 11/1/2015 Socket Communication

35 11/1/2015 Remote Procedure Calls l Remote procedure call (RPC) abstracts procedure calls between processes on networked systems. Stubs – client-side proxy for the actual procedure on the server. l The client-side stub locates the server and marshalls the parameters. l The server-side stub receives this message, unpacks the marshalled parameters, and peforms the procedure on the server.

36 11/1/2015 Execution of RPC

37 11/1/2015 Remote Method Invocation l Remote Method Invocation (RMI) is a Java mechanism similar to RPCs. l RMI allows a Java program on one machine to invoke a method on a remote object.

38 11/1/2015 Marshalling Parameters