Wednesday, 10 June 2015

PROCESS MANAGEMENT

             

                      *PROCESS MANAGEMENT:-


              *What is a Process? 


A process is sequential program in execution. A process defines the fundamental unit of computation for the computer. Components of process are :-

1. Object Program
2. Data
3. Resources
4. Status of the process execution. 


  Object program i.e. code to be executed. Data is used for executing the program. While executing the program, it may require some resources. Last component is used for verifying the status of the process execution. A process can run to completion only when all requested resources have been allocated to the process. Two or more processes could be executing the same program, each using their own data and resources.

              *Process & Program:-


1.Process:-

            it is a dynamic entity, that is a program in execution. A process is a sequence of information executions. Process exists in a limited span of time. Two or more processes could be executing the same program, each using their own data and resources.

2.Program:-

             it is a static entity made up of program statement. Program contains the instructions. A program exists at single place in space and continues to exist. A program does not perform the action by itself.

                      *Thread


A thread is a flow of execution through the process code, with its own program counter, system registers and stack. Threads are a popular way to improve application performance through parallelism. A thread is sometimes called a light weight process. Each thread belongs to exactly one process and no thread can exist outside a process. Each thread represents a separate flow of control.

               *Types of Thread :-


Threads is implemented in two ways :-

1.User Level:-

                In a user thread, all of the work of thread management is done by the application and the kernel is not aware of the existence of threads. The thread library contains code for creating and destroying threads, for passing message and data between threads, for scheduling thread execution and for saving and restoring thread contexts.


2.Kernel Level :-

                   In Kernel level thread, thread management done by the Kernel. There is no thread management code in the application area. Kernel threads are supported directly by the operating system. Any application can be programmed to be multithreaded.

                      *Process State:-


As a process executes, it changes state

1.New :-

         A process that just been created.

2.Ready :-

            Ready processes are waiting to have the processor allocated to them by the operating system so  that they can run.

3.Running :-

             The process that is currently being executed. A running process possesses all the resources needed for its execution, including the processor.

4.Waiting :-

              A process that can not execute until some event occurs such as the completion of an I/O operation. The running process may become suspended by invoking an I/O module.

5.Terminated :-

                A process that has been released from the pool of executable processes by the operating system.

Whenever processes changes state, the operating system reacts by placing the process PCB in the list that corresponds to its new state. Only one process can be running on any processor at any instant and many processes may be ready and waiting state.


                        *Suspended Process:-


Suspended process is not immediately available for execution.The process may or may not be waiting on an event.For preventing the execution, process is suspend by OS, parent process, process itself.

Reasons for process suspension :-

1.Swapping

2.Timing

3.Interactive user request

4.Parent process request


                            1.Swapping :-


OS needs to release required main memory to bring in a process that is ready to execute.

                           2.Timing :-


  Process may be suspended while waiting for the next time interval.

                       3.Interactive user request :-


 Process may be suspended for debugging purpose by user.

                         4.Parent process request :-


 To modify the suspended process or to coordinate the activity of  various descendants.

                       *Process Control Block (PCB)


Each process contains the process control block (PCB). PCB is the data structure used by the operating system. Operating system groups all information that needs about particular process.

1.Pointer :-

           Pointer points to another process control block. Pointer is used for maintaining the scheduling list.

2.Process State :-

                   Process state may be new, ready, running, waiting and so on.

3.Program Counter :-

                    It indicates the address of the next instruction to be executed for this process.

4.Event information :-

                       For a process in the blocked state this field contains information concerning the event for which the process is waiting.

5.CPU register :-

                 It indicates general purpose register, stack pointers, index registers and accumulators etc. number of register and type of register totally depends upon the computer architecture.

6.Memory Management Information :-

                                  This information may include the value of base and limit register. This information is useful for deallocating the memory when the process terminates.

7.Accounting Information :-

                         This information includes the amount of CPU and real time used, time limits, job or process numbers, account numbers etc.

                    *Process Scheduling:-


Multiprogramming operating system allows more than one process to be loaded into the executable memory at a time and for the loaded process to share the CPU using time multiplexing. The scheduling mechanism is the part of the process manager that handles the removal of the running process from the CPU and the selection of another process on the basis of particular strategy.


                       *Process Scheduling Queues:-


When the process enters into the system, they are put into a job queue. This queue consists of all processes in the system. The operating system also has other queues. Device queue is a queue for which a list of processes waiting for a particular I/O device. Each device has its own device queue. Queue is represented by rectangular box. The circles represent the resources that serve the queues. The arrows indicate the flow of processes in the system.

1.Job queue :–

                set of all processes in the system.


2.Ready queue :– 

                 set of all processes residing in main memory, ready and waiting to execute.

3.Device queues :–

                      set of processes waiting for an I/O device.Process migration between the various queues.

                        *Schedulers:-


A process migrate between the various scheduling queues throughout its lifetime. The operating system must select, for scheduling purposes, processes from theses queues in some fashion. The selection process is carried out by the appropriate scheduler. Types of schedules:

1.Long Term Scheduler
2.Short Term Scheduler
3.Medium Term Scheduler 


                       *Long Term Scheduler :-


It is also called job scheduler. Long term scheduler determines which programs are admitted to the system for processing. Job scheduler selects processes from the queue and loads them into memory for execution. Process loads into the memory for CPU scheduler. The primary objective of the job scheduler is to provide a balanced mix of jobs, such as I/O bound and processor bound. It also controls the degree of multiprogramming. When process changes the state from new to ready, then there is a long term scheduler.

                   *Short Term Scheduler:-


It is also called CPU scheduler. Main objective is increasing system performance in accordance with the chosen set of criteria. It is the change of ready state to running state of the process. CPU scheduler selects from among the processes that are ready to execute and allocates the CPU to one of them. Short term scheduler also known as dispatcher, execute most frequently and makes the fine grained decision of which process to execute next. Short term scheduler is faster than long tern scheduler.

                    *Medium Term Scheduler :-


Medium term scheduling is part of the swapping function. It removes the processes from the memory. It reduces the degree of multiprogramming. The medium term scheduler is in charge of handling the swapped out-processes.

                    *Context Switch:-


When the scheduler switches the CPU from executing one process to executing another, the context switcher saves the content of all processor registers for the process being removed from the CPU in its process being removed from the CPU in its process descriptor. The context of a process is represented in the process control block (PCB) of a process. Context switch time is pure overhead. Context switching can significantly affect performance.

1.Program Counter
2.Scheduling Information
3.Base and limit register value
4.Currently used register
5.Changed State
6.I/O State
7.Accounting


                     *Operation on Process:-


Several operations are possible on the process. Process must be created and deleted dynamically. Operating system must provide the environment for the process operation. We discuss the two main operations on processes.

1.Create a process

2.Terminate a process


                         *Process Creation:-


Operating system creates a new process with the specified or default attributes and identifier. A process may create several new subprocesses. Syntax for creating new process is :
CREATE ( processed, attributes )
Two names are used in the process they are parent process and child process.  Parent process is a creating process. Child process is created by the parent process. Child process may create another subprocess. So it forms a tree of processes. When operating system issues a CREATE system call, it obtains a new process control block from the pool of free memory, fills the fields with provided and default parameters, and insert the PCB into the ready list. Thus it makes the specified process eligible to run the process.

            When a process creates a new process, two possibilities exist in terms of execution.

1.The parent continues to execute concurrently with its children.

2.The parent waits until some or all of its children have terminated.

For address space, two possibilities occur:-

1.The child process is a duplicate of the parent process.

2.The child process has a program loaded into it.

            *Process Termination:-


DELETE system call is used for terminating a process. A process may delete itself or by another process. A process can cause the termination of another process via an appropriate system call. The O/S reacts by reclaiming all resources allocated to the specified process, closing files opened by or for the process. PCB is also removed from its place of residence in the list and is returned to the free pool. The DELETE service is normally invoked  as a part of orderly program termination.

  Following are the resources for terminating the child process by parent process.

1.The task given to the child is no longer required.

2.Child has exceeded its usage of some of the resources that it has been  allocated.

3.Operating system does not allow a child to continue if its parent terminates.


                         *Cooperating Processes:-


Co-operating process is a process that can affect or be affected by the other processes while executing. If suppose any process is sharing data with other processes, then it is called co-operating process. Benefit of the co-operating processes are :

1.Sharing of information

2.Increases computation speed

3.Modularity

4.Convenience

              *Interprocess Communication (IPC):-


Cooperating processes require an interprocess communication (IPC) mechanism that will allow them to exchange data and information. There are two fundamental models of interprocess communication:

1.Shared memory:
                In the shared-memory model, a region of memory that is shared by cooperating processes is established. Processes can then exchange information by reading and writing data to the shared region.

2.Message passing:
                     In this communication takes place by means of messages exchanged between the cooperating processes.























No comments:

Post a Comment