program in execution, as mentioned, is a process. A time-shared user program
such as a compiler is a process. A word-processing program being run by an individual user on a PC is a process. A system task, such as sending ©utput
to a printer, can also be a process (or at least part of one). For now, you can
consider a process to be a job or a time-shared program, but later you will learn
that the concept is more general. As we shall see in Chapter 3, it is possible
to provide system calls that allow processes to create subprocesses to execute
concurrently.
A process needs certain resources—including CPU time, memory, files,
and I/O devices—to accomplish its task. These resources are either given to
the process when it is created or allocated to it while it is running. In addition
to the various physical and logical resources that a process obtains when it is
created, various initialization data (input) may be passed along. For example,
consider a process whose function is to display the status of a file on the screen
of a terminal. The process will be given as an input the name of the file and will
execute the appropriate instructions and system calls to obtain and display
on the terminal the desired information. When the process terminates, the
operating system will reclaim any reusable resources.
We emphasize that a program by itself is not a process; a program is a passive
entity, such as the contents of a file stored on disk, whereas a process is an active
entity. A single-threaded process has one program counter specifying the next
instruction to execute. (Threads will be covered in Chapter 4.) The execution
of such a process must be sequential. The CPU executes one instruction of the
process after another, until the process completes. Further, at any time, one
instruction at most is executed on behalf of the process. Thus, although two
processes may be associated with the same program, they are nevertheless
considered two separate execution sequences. A multithreaded process has
multiple program counters, each pointing to the next instruction to execute for
a given thread.
A process is the unit of work in a system. Such a system consists of a
collection of processes, some of which are operating-system processes (those
that execute system code) and the rest of which are user processes (those that
execute user code). All these processes can potentially execute concurrently—
by multiplexing the CPU among them on a single CPU, for example.
The operating system is responsible for the following activities in connection
with process management:
- Creating and deleting both user and system processes
- Suspending and resuming processes
- Providing mechanisms for process synchronization
- Providing mechanisms for process communication
- Providing mechanisms for deadlock handling
No comments:
Post a Comment