Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 3: Processes Process Concept Process Scheduling

Similar presentations


Presentation on theme: "Chapter 3: Processes Process Concept Process Scheduling"— Presentation transcript:

1 Chapter 3: Processes Process Concept Process Scheduling
Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server Systems

2 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: program counter (number of instruction) Stack (local variable) data section (global variable)

3 Process State As a process executes, it changes 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.

4 Diagram of Process State

5 Process Control Block (PCB)
PCB contains the information associated with each process like: Process state: new, ready, running…etc. Program counter: The address of the next instruction to be executed. CPU registers: This state information must be saved when an interrupt occurs. CPU scheduling information: includes Process Priority, and pointers to scheduling queues. Memory-management information: includes base register and the page table. Accounting information: includes the amount of CPU time used, time limits, account numbers, job number…etc. I/O status information: includes list of I/O devices allocated for this process, list of open files…etc.

6 Process Control Block (PCB)

7 CPU Switch From Process to Process

8 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. Process migration between the various queues.

9 Ready Queue And Various I/O Device Queues

10 Process Scheduling Queues (Cont.)
A new process is initially put in the ready queue. It waits in the ready queue until it’s selected for execution. Once the process is executing, one of several events could occur: The process could issue an I/O request, and then be placed in I/O queue. The process could create a new sub-process and wait for its termination. The process could be removed from CPU, as a result of an interrupt, and put back in the ready queue.

11 Representation of Process Scheduling

12 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.

13 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.

14 Schedulers (Cont.) The long-term scheduler should select a good process mix of I/O bound and CPU bound processes. Some systems may introduce an additional intermediate level of scheduling. This medium-term scheduler is used with the Swapping process, where it removes processes from memory (thus reduces the degree of multiprogramming) and reintroduce them later into memory to continue there execution.

15 Addition of Medium Term Scheduling

16 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. Context-switch time is overhead; the system does no useful work while switching. Time dependent on hardware support. Programmers are using threads whenever possible to avoid the performance bottleneck presented by the context switching.


Download ppt "Chapter 3: Processes Process Concept Process Scheduling"

Similar presentations


Ads by Google