Professional Documents
Culture Documents
Unit 1
Chapter 2
PROCESS MANAGEMENT
2.1 Introduction
A process can be thought of as a program in execution. A process will need certain resourcessuch as CPU time, memory, files, and I/O devices-to accomplish its task. These resources
are allocated to the process either when it is created or while it is executing.
A process is the unit of work in most systems. Such a system consists of a collection of
processes: Operating-system processes execute system code, and user processes execute user
code. All these processes may execute concurrently.
Although traditionally a process contained only a single thread of control as it ran, most
modern operating systems now support processes that have multiple threads.
The operating system is responsible for the following activities in connection with
process and thread management: the creation and deletion of both user and system
processes; the scheduling of processes; and the provision of mechanisms for
synchronization, communication, and deadlock handling for processes.
Chapter 2
Unit 1
In Fig. 2-l (c) we see that viewed over a long enough time interval, all the processes have
made progress, but at any given instant only one process is actually running.
Chapter 2
Unit 1
the operating system decides that it has the resources to run another job, it creates a new
process and runs the next job from the input queue in it.
Chapter 2
Unit 1
4 | Page
Chapter 2
Unit 1
Accounting information: This information includes the amount of CPU and real time used,
time limits, account numbers, job or process numbers, and so on.
I/O status information: The information includes the list of
process, a list of open files, and so on.
The PCB simply serves as the repository for any information that may vary from process to
process.
All interrupts start by saving the registers, often in the process table entry for the current
process. Then the information pushed onto the stack by the interrupt is removed and the stack
pointer is set to point to a temporary stack used by the process handler. Actions such as
saving the registers and setting the stack pointer cannot even be expressed in high-level
languages such as C, so they are performed by a small assembly language routine, usually the
same one for all interrupts since the work of saving the registers is identical, no matter what
the cause of the interrupt is.
When this routine is finished, it calls a C procedure to do the rest of the work for this specific
interrupt type. When it has done its job, possibly making some process now ready, the
scheduler is called to see who to run next. After that, control is passed back to the assembly
language code to load up the registers and memory map for the now-current process and start
it running.
Interrupt handling and scheduling are summarized in Figure. 2-6.
Figure 2-6. Skeleton of what the lowest level of the operating system does when an
interrupt occurs.
When the process finishes, the operating system displays a prompt character and waits for a
new command. When it receives the command, it loads a new program into memory,
overwriting the first one.
In Figure 2.7, the return code s is -1 if an error has occurred, pid is a process ID, and residual
is the remaining time in the previous alarm. The parameters are what the names suggest.
2. Process Management System Calls in Windows
Let us now look at the Windows system calls dealing with process management. The main
ones are listed in Figure 2.8.
Figure 2.8. Some of the Win32 calls for managing processes, threads, and fibers.