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 Chapter 3: Processes ■ ■ ■ ■ ■ ■ 3.3 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Process Concept Process Concept ■ ● Batch system – jobs ● Time-shared systems – user programs or tasks ■ jobprocess ■ !" # ■ ● program counter ● stack ● data section 3.4 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Process in Memory Process in Memory 3.5 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Process State Process State ■ $state ● new: The process is being created ● running: Instructions are being executed ● waiting: The process is waiting for some event to occur ● ready: The process is waiting to be assigned to a processor ● terminated: The process has finished execution 3.6 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Diagram of Process State Diagram of Process State 3.7 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Process Control Block (PCB) Process Control Block (PCB) % ■ ■ ■ & ■ & ■ ' ■ ■ ( 3.8 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Process Control Block (PCB) Process Control Block (PCB) 3.9 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 CPU Switch From Process to Process CPU Switch From Process to Process 3.10 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Process Scheduling Queues Process Scheduling Queues ■ Job queue! ■ Ready queue! $% ■ Device queues!% ( ■ # [...]... receive a message from mailbox A Operating System Concepts - 7th Edition, Feb 7, 2006 3. 33 Silberschatz, Galvin and Gagne ©2005 Indirect Communication s Mailbox sharing q P1, P2, and P3 share mailbox A q P1, sends; P2 and P3 receive q Who gets the message? s Solutions q Allow a link to be associated with at most two processes q Allow only one process at a time to execute a receive operation q Allow the... share a mailbox s Properties of communication link q Link established only if processes share a common mailbox q A link may be associated with many processes q Each pair of processes may share several communication links q Link may be unidirectional or bi-directional Operating System Concepts - 7th Edition, Feb 7, 2006 3. 32 Silberschatz, Galvin and Gagne ©2005 Indirect Communication s Operations q... 2006 3. 35 Silberschatz, Galvin and Gagne ©2005 Buffering s 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 Operating System Concepts - 7th Edition, Feb 7, 2006 3. 36 Silberschatz,... one pair of communicating processes q Between each pair there exists exactly one link q The link may be unidirectional, but is usually bi-directional Operating System Concepts - 7th Edition, Feb 7, 2006 3. 31 Silberschatz, Galvin and Gagne ©2005 Indirect Communication s Messages are directed and received from mailboxes (also referred to as ports) q Each mailbox has a unique id q Processes can communicate... no useful work while switching s Time dependent on hardware support Operating System Concepts - 7th Edition, Feb 7, 2006 3. 16 Silberschatz, Galvin and Gagne ©2005 Process Creation s Parent process create children processes, which, in turn create other processes, forming a tree of processes s Resource sharing q Parent and children share all resources q Children share subset of parent’s resources q Parent... Edition, Feb 7, 2006 3. 23 Silberschatz, Galvin and Gagne ©2005 Producer-Consumer Problem s Paradigm for cooperating processes, producer process produces information that is consumed by a consumer process q unbounded-buffer places no practical limit on the size of the buffer q bounded-buffer assumes that there is a fixed buffer size Operating System Concepts - 7th Edition, Feb 7, 2006 3. 24 Silberschatz,... variable? s Is a link unidirectional or bi-directional? Operating System Concepts - 7th Edition, Feb 7, 2006 3. 29 Silberschatz, Galvin and Gagne ©2005 Communications Models Operating System Concepts - 7th Edition, Feb 7, 2006 3. 30 Silberschatz, Galvin and Gagne ©2005 Direct Communication s Processes must name each other explicitly: q send (P, message) – send a message to process P q receive(Q, message)... bus) q logical (e.g., logical properties) Operating System Concepts - 7th Edition, Feb 7, 2006 3. 28 Silberschatz, Galvin and Gagne ©2005 Implementation Questions s How are links established? s Can a link be associated with more than two processes? s How many links can there be between every pair of communicating processes? s What is the capacity of a link? s Is the size of a message that the link can accommodate... Various I/O Device Queues Operating System Concepts - 7th Edition, Feb 7, 2006 3. 11 Silberschatz, Galvin and Gagne ©2005 Representation of Process Scheduling Operating System Concepts - 7th Edition, Feb 7, 2006 3. 12 Silberschatz, Galvin and Gagne ©2005 Schedulers s Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue s Short-term scheduler (or CPU... for the child to complete */ wait (NULL); printf ("Child Complete"); exit(0); } } Operating System Concepts - 7th Edition, Feb 7, 2006 3. 20 Silberschatz, Galvin and Gagne ©2005 A tree of processes on a typical Solaris Operating System Concepts - 7th Edition, Feb 7, 2006 3. 21 Silberschatz, Galvin and Gagne ©2005 Process Termination s Process executes last statement and asks the operating system to delete . 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 Chapter 3: Processes ■ ■ ■ ■ ■ ■ 3. 3 Silberschatz,. Processes ■ ■ ■ ■ ■ ■ 3. 3 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Process. counter ● stack ● data section 3. 4 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Process in Memory Process in Memory 3. 5 Silberschatz, Galvin and Gagne