Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept
3.2 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 3: Process-Concept Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication in Client-Server Systems
3.3 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Objectives To introduce the notion of a process -- a program in execution, which forms the basis of all computation To describe the various features of processes, including scheduling, creation and termination, and communication To describe communication in client-server systems
3.4 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process Concept An operating system executes a variety of programs: Batch system – jobs Time-shared systems – user programs or tasks Textbook uses the terms job and process almost interchangeably Process – a program in execution; process execution must progress in sequential fashion A process includes its current activity: Program counter. Stack: temporary data such as function parameters- return address - local variables. Data section: global variables. May include a heap: memory that is dynamically allocated during process run time.
3.5 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process Concept A program becomes a process once loaded into memory. Double click on icon Enter the executable file name on the command line Ex: Several copies of program such as web browser can be loaded onto memory. Each copy represents a process has its own: Stack Heap Program counter Data
3.6 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process in Memory
3.7 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process State As a process executes, it changes state. The state is the current activity of the process and it can be in one of the following states. 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.8 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Diagram of Process State
3.9 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process Control Block (PCB) each process in OS is represented by Process Control Block (PCB) Information associated with each process Process state: new, ready, running, waiting, halted Program counter: address of next instruction to be executed in process CPU registers: depending on computer architecture CPU scheduling information: process priority, pointers to scheduling queues.
3.10 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process Control Block (PCB) Continue each process in OS is represented by Process Control Block (PCB) Information associated with each process Memory-management information: may include the value of the base and limit registers, page tables or segment tables, it depends on memory system used by OS. Accounting information: amount of CPU used, real time used, time limit, account number, process number and so on I/O status information: a list of I/O devices allocated to the process (P), a list of open files and so on. In short: PCB is a repository for any information that may vary from P to P.
3.11 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process Control Block (PCB)
3.12 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition CPU Switch From Process to Process
3.13 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Threads A process runs one copy of a program is a single thread. A single thread of instruction is being executed. That means one task a time. Many operating systems have extended the process concept to allow a process to have multiple threads (control) of execution (perform more than one task at a time). Thus PCB is expanded to include information for each thread.
3.14 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process Scheduling Process Scheduling Queues Process Scheduler: selects an available process for program execution on the CPU Job queue – set of all processes entering 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 Processes migrate among the various queues
3.15 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Ready and Device I/O Queues The queue is generally stored as linked list: a ready-queue header contains pointers to the first and final PCBs in the list. Each PCB includes a pointer field that point to the next PCB in the ready queue. System includes other queues When a P is allocated the CPU, it executed for a while and quit (interrupt, or wait for occurrence of an event such as a competition of I/O request. If the P makes an I/O request to a shared device such as a disk. The P may have to wait for disk if there are many processes. The list of Ps waiting for a particular I/O device is called device queue.
3.16 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Ready Queue And Various I/O Device Queues
3.17 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Representation of Process Scheduling A new P enter the ready queue. It waits until it is selected for execution or dispatched. Once the P is allocated the CPU and is executed one of several events could occur: The P could issue I/O request and then placed in an I/O queue. The P could create a new subprocess and wait fir the subprocess’s for termination. The P could be removed forcibly from the CPU as a result of interrupt and go back to the ready queue.
3.18 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Representation of Process Scheduling