Introduction to Operating Systems: Unit II(a): Process Management

Process Management

Process Management - Introduction to Operating Systems

Process term is used in MULTICS system in the 1960. Process is an asynchronous activity. Process is an active entity that requires a set of resources, including a processor, program counter, registers to perform its function.

UNIT II: Process Management

CHAPTER 2: Process Management

Syllabus

Processes - Process Concept - Process Scheduling - Operations on Processes - Inter-process Communication; CPU Scheduling - Scheduling criteria - Scheduling algorithms: Threads - Multithread Models - Threading issues; Process Synchronization - The Critical-Section problem - Synchronization hardware - Semaphores - Mutex - Classical problems of synchronization - Monitors; Deadlock - Methods for handling deadlocks, Deadlock prevention, Deadlock avoidance, Deadlock detection, Recovery from deadlock.


Process Concept

AU: Dec.-17

• Process term is used in MULTICS system in the 1960. Process is an asynchronous activity.

• Process is an active entity that requires a set of resources, including a processor, program counter, registers to perform its function. Multiple processes may be associated with one program.

• Process execution must progress in sequential order. It also called task. Task is a single instance of an executable program. Fig. 2.1.1 shows memory layout for a process.

• Each process has its own address space. Address space is divided into two regions : 1. Text region 2. Data region 3. Stack region

Text region: It stores the code that that the processor executes.

Data region: It stores variables and dynamically allocated memory that the process uses during execution.

Stack region: It stores instructions and local variables for active procedure calls.

• Process is a dynamic entity that executes a program on a Higher particular set of data using resources allocated by the operating system.

• A process can run to completion only when all requested hardware and software resources have been allocated to the process.

• Program is a passive entity. Program becomes process when executable file loaded intomemory. A process may be independent of other processes in the system.

• After booting operating system, it creates foreground processes and

background processes.

• Foreground processes interact with user and background processes is used by system. Background processes are related e-mail, web pages, news and printing.

• A process is used as a fundamental unit for resource allocation in operating system. A process normally has its own private memory area in which it runs.

• Text region contains executable instructions. It is be placed below the heap or Bold forines stack.

• An initialized data region contains the static and global variables that are initialized by the user.

• Un-initialized data region contains all static and global variables that are initialized by kernel to zero.

• Heap is used for dynamic memory allocation and stack contains program counter.

Difference between Process and Program

Process Control Block

• Operating system keeps an internal data structure to describe each process it manages.

• When OS creates process, it creates this process descriptor. In some operating system, it calls Process Control Block (PCB).

• Fig. 2.1.2 shows process control block.

• Process control block will change according to the operating system. PCB is also called task control block.

• The PCB is identified by an integer Process ID (PID). When a process is  running, its hardware state is inside the CPU.

• When the OS stops running a process, it saves the register's values in the PCB.

• When a process is created by operating system, it allocates a PCB for it. OS initializes PCB and puts PCB on the correct queue. Following information is stored in process control block.

1. Process identification: Each process is uniquely identified by the user's identification and a pointer connecting it to its descriptor.

2. Priority number: Operating system allocates the priority number to each process. According to the priority number it allocates the resources.

3. Program counter: The PC indicates the address of the next instruction to be executed for this current process.

4. Memory allocation: It contains the value of the base registers, limit registers and the page tables depending on the memory system used by the operating system.

5. I/O status information: It maintains information about the open files, list of I/O devices allocated to the process etc.

6. List of open files: Process uses number of files for operation. Operating system keeps track of all opened file by this process.

7. Process state: Process may be in any one of the state: new, ready, running, and waiting, terminate.

• When process changes the state, the operating system must update information in the process's process control block. Process control block maintain other information which is not included in PCB block diagram. es This information includes CPU190 scheduling, file management, or input-output management information.

• Fig. 2.1.3 shows process table with PCB.

• When process is created, hardware registers and flags values are set by loader or linker.

• Operating system maintains pointers to each process's PCB in a per user process table or system wide process table. This information is used to access PCB quickly.

Process States

• Each process has an execution state which indicates what process is currently doing. The process descriptor is the basic data structure used to represent the specific state for each process.

• Fig. 2.1.4 shows a process state diagram. A state diagram is composed of a set of states and transitions between states.

• State diagram is used by process manager to determine the type of service to provide to the process.

• The process states are as follows:

1. New 2. Ready 3. Running 4. Waiting 5. Terminated

• New: Operating system creates new process by using fork() system call. These process are newly created process and resources are not allocated.

• Ready: The process is competing for the CPU. Process reaches to the head of the list (queue).

• Running The process that is currently being executed. Operating system allocates all the hardware and software resources to the process for execution.

• Waiting A process is waiting until some event occurs such as the completion of an input-output operation.

• Terminated: A process completes its operations and releases all resources.

• Operating system maintains a ready list of ready process and a blocked list of blocked processes. The ready list is maintained in priority order and blocked list is typically unordered.

• The act of assigning a processor to the first process on the ready list is called dispatching and is performed by a system entity called the dispatcher.

• When process is in new state, the program remains in the secondary storage. Here process itself is not in the main memory and space is not allocated.

• The process exists a system because of two reasons :

1. Process is terminated when it completes its operation.

2. Process aborts due to an unrecoverable error.

• To prevent any one process from continuously using the system, the operating system sets a hardware interrupting clock to allow a process to run for a specific time interval or time quantum.

• The process may request a resource when it is in the running state. In most of the operating system, if a running process requests an immediately available resources the process is allowed to continue in the running state.

• From the blocked state, the process can move to the ready state only by being allocated the requested resource.

• User only initiate process state transition is blocked and remaining all other state transitions is initiated by the operating system.


Suspended Processes

• Each process to be executed must be loaded into main memory. In uniprocessor system, processor remains idle because of execution speed mismatch of processor  I/O devices. An I/O device is slower than processor.

• Main memory accommodates multiple processes and the processor select next I process when one process is blocked. So even with multiprogramming operating system, a processor could be idle most of the time. Main memory size is increased for accommodating more processes but cost will increase.

Suspended state: when all of the processes in main memory are in the blocked state, the operating system can suspend one process by putting it in the suspend state and transferring it to disk. The space that is freed in main memory can then goo be used to bring in another process.

• Characteristics of a suspended process :

1. The process cannot execute immediately.

2. The process may or may not be waiting for an event.

3. The process was placed in a suspended state by a parent process, or itself or by operating system.

4. The process may not be removed from suspended state until its turn comes.


University Question

1. What is a process? Discuss components of process and various states of a process with the help of a process state transition diagram.   AU Dec.-17, Marks 8

Introduction to Operating Systems: Unit II(a): Process Management : Tag: : Process Management - Introduction to Operating Systems - Process Management