Princess Nora University Faculty of Computer Information Systems
- Slides: 33
Princess Nora University Faculty of Computer & Information Systems Computer science Department Operating Systems (CS 340 D)
(Chapter-3) Process-Concept
Chapter 3: Process-Concept 1. Process Concept 2. Process Scheduling 3. Inter-process Communication 3 Dr. Abeer Mahmoud
OBJECTIVES: Ø To introduce the notion of a process Ø To describe the various features of processes, including scheduling, creation and termination, and communication 4 Dr. Abeer Mahmoud
Process Concept �System consists of a collection of processes: q Operating q system processes executing system code User processes executing user code � The terms job and process are used almost interchangeably, and both refer to the same meaning: = ( a program that is loaded into memory and in execution) 5 Dr. Abeer Mahmoud
Process Concept (cont. . ) � Program : is a collection of instruction in a code manner , which is sometimes known as the text section. � Program = passive entity � Process =Active entity � Process : is more general than program as it includes more details such as : o Text section o Stacko Data section: o The current activity: o Heap 6 Dr. Abeer Mahmoud
The Process (cont. . ) contains temporary data (such as function parameters, return addresses, and local variables The current activity: the value of the program counter & contents of the processor’s registers. is memory that is dynamically allocated during process run time. which contains global variables. which is program code. 7 Dr. Abeer Mahmoud
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 (e. g. An I/O completion). � Ready: the process is waiting to be assigned to a processor � Terminated: the process has finished execution � Only one process can be running on any processor at any instant. Many processes may be ready and waiting. 8 Dr. Abeer Mahmoud
Diagram of Process State 9 Dr. Abeer Mahmoud
Process Control Block (PCB) � Each process is represented in the operating system by a process control block (PCB) � PCB contains many information including : Process state Program counter CPU registers CPU scheduling information Values of program counter & CPU registers must be saved when an interrupt occurs to allow the process to be continued correctly afterward e. g. a process priority Memory-management information Accounting information: 10 I/O status information e. g. when the process was last run, how much CPU time it has used Dr. Abeer Mahmoud It includes the list of I/O devices allocated to
Process Control Block (PCB) (cont. . ) 11 Dr. Abeer Mahmoud
CPU Switch From Process to Process 12 Dr. Abeer Mahmoud
PROCESS SCHEDULING 13 Dr. Abeer Mahmoud
Process Scheduling � Multiprogramming aims to have some process running at all times to maximize CPU utilization. � Time sharing aims to switch the CPU among processes so frequently user interact with each program while it is running. � Process scheduler selects an process (from a set of several available processes) for execution on the CPU. 14 Dr. Abeer Mahmoud
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 � This queue is generally stored as a linked list. � Device queues – set of processes waiting for an I/O device � Each device has its own device queue 15 Dr. Abeer Mahmoud
Process Scheduling Queues (cont. ) � Processes migrate among the various queues: �A new process is initially put in the ready queue. � It waits there until it is selected for execution. � Once the process is allocated the CPU and is executing, one of several events could occur: The process could issue an I/O request and then be placed in an I/O queue. 16 The process could create a new subprocess and wait for the sub-process’s termination The process could be removed forcibly from the CPU as a result of an interrupt, and be put back in the ready queue. Dr. Abeer Mahmoud
Process Scheduling Queues (cont. ) �A process continues this cycle until it terminates, at which time it is removed from all queues and has its PCB and resources deallocated. 17 Dr. Abeer Mahmoud
Representation of Process Scheduling 18 Queuing diagram Dr. Abeer Mahmoud
Schedulers � The operating system must select processes scheduling for these queues. � The selection process is carried out by the appropriate scheduler. � Long-term scheduler (or job scheduler) – selects which processes should be brought from mass-storage into RAM (to the ready queue ) � Short-term scheduler (or CPU scheduler) – selects which process (from ready queue) should be executed next and allocates CPU 19 Dr. Abeer Mahmoud
Schedulers � 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 20 Dr. Abeer Mahmoud
Schedulers (Cont) �Processes can be described as either: I/O-bound process CPU-bound process – spends more time doing I/O than computations, many computations; few very long short CPU intervals. 21 Dr. Abeer Mahmoud
Schedulers (Cont) � The long-term scheduler must select a good process mix of I/O-bound and CPU-bound processes to improve total performance. If all processes are I/O bound If all processes are CPU bound • the ready queue will almost • the I/O waiting queue will always be empty, almost always be empty, • the short-term scheduler • devices will go unused…. will have little to do… • (minimize devices • . (minimize CPU utilization) 22 Dr. Abeer Mahmoud
Medium Term Scheduling q Sometimes it can be advantageous to remove processes from RAM ……. (swap out) q Later, the process can be reintroduced into RAM ……. (swap in), and its execution can be continued where it left off. q This scheme is called swapping. ( done by mediumterm scheduler) q Swapping may be necessary to improve the process mix q Or because a change in memory requirements has exceeded available memory 23 Dr. Abeer Mahmoud
Addition of Medium Term Scheduling 24 Dr. Abeer Mahmoud
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 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 �
INTERPROCESS COMMUNICATION 26 Dr. Abeer Mahmoud
Interprocess Communication Processes within a system may be independent Cannot affect or be affected by the execution of another process. 27 cooperating Can affect or be affected by the execution of another process Dr. Abeer Mahmoud
Interprocess Communication � Reasons 1. (/advantages) for cooperating processes: Information sharing : (e. g. shared file) 2. Computation speedup: � To make a particular task run faster, we must break it into subtasks, each of which will be executing in parallel with the others. �This can be achieved only if the computer has multiple processing elements (e. g. CPUs). 28 Dr. Abeer Mahmoud
Interprocess Communication � Reasons (/advantages) for cooperating processes: 3. Modularity: �We may want to construct the system in a modular fashion (i. e. dividing the system functions into separate processes) 4. Convenience �An individual user may work on many tasks at the same time. 29 Dr. Abeer Mahmoud
Interprocess Communication (Cont. ) � Cooperating processes need interprocess communication (IPC) � IPC: mechanism that will allow cooperating processes to exchange data and information. 30 Dr. Abeer Mahmoud
Interprocess Communication (Cont. ) � Two models of IPC: process can exchange information by Shared memory: Message passing • reading and writing data to • By messages the shared region. exchanged between the cooperating processes. • Shared memory is faster • Useful for exchanging than message passing …. smaller amounts of data, because no conflicts need • Because message passing be avoided. systems requires more • Easier to implement than system calls (interrupts). shared memory. 31 Dr. Abeer Mahmoud
Communications Models Message passing model 32 Shared memory model Dr. Abeer Mahmoud
Thank you End of Chapter 3 33 Dr. Abeer Mahmoud
- Gstt johor
- Princess nora university
- Bridgeport engineering department
- University of bridgeport computer engineering
- Florida state university ms in cs
- Brown university computer science
- Herszon kherson maritime college of merchant marine fleet
- Hubert kairuki memorial university faculty of medicine
- Hyperparathyreosis
- Applied medical sciences
- Mendel university faculty of business and economics
- Singularity university faculty
- Territorial matrix vs interterritorial matrix
- Ascaris lumbricoides ova
- Feup university of porto
- Ldap cuni
- Faculty of veterinary medicine cairo university logo
- Faculty of law of the university of zagreb
- University of montenegro faculty of law
- University of kragujevac faculty of technical sciences
- University of cologne faculty of management
- Leading university faculty
- Hacettepe university faculty of medicine
- Conus arteriosus
- Semmelweis university faculty of medicine
- Faculty of engineering lebanese university
- York university myfile
- University of debrecen faculty of economics and business
- Clemson ece lab manual
- Faculty of veterinary medicine cairo university
- Faculty of mechanical engineering thammasat university
- Mendel university faculty of business and economics
- Chronic meningitis
- Mahidol university public health