3 Process
3 Process
Process Concept
a process is a program in execution. A process is more than the
program code, which is sometimes known as the text section. It
also includes the current activity, as represented by the value of
the program counter and the contents of the processor's
registers.
A process generally also includes the process stack, which
contains temporary data (such as function parameters, return
addresses, and local variables),
and a data section, which contains global variables.
A process may also include a heap, which is memory that is
dynamically allocated during process run time.
a program is a passive entity, such as a file containing a list of
instructions stored on disk, whereas a process is an active
entity, with a program counter specifying the next instruction to
execute and a set of associated resources. A program becomes
a process when an executable file is loaded into memory.
Process in Memory
Process State
As a process executes, it changes state. The state of a
process is defined in part by the current activity of that
process. Each process may be in one of the following states:
new: The process is being created
running: Instructions are being executed
waiting: The process is waiting for some event to occur
ready: The process is waiting to be assigned to a
processor
terminated: The process has finished execution
Diagram of Process State
Process Control Block (PCB)
Job queue – As processes enter the system, they are put into
a job queue, which consists 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. A ready-queue header contains pointers to the
first and final PCBs in the list. Each PCB includes a pointer
field that points to the next PCB in the ready queue.
Process Scheduling Queues
perating System Concepts - 7th Edition, Feb 7, 2006 3.14 Silberschatz, Galvin and Gagne
Representation of Process
Scheduling
Schedulers
Process Creation
A process may create several new processes, via a
create-process system call, during the course of
execution. The creating process is called a parent
process, and the new processes are called the children
of that process.
Each of these new processes may in turn create other
processes, forming a tree of processes.
Process Creation
Most operating systems (including UNIX and the Windows
family of operating systems) identify processes according
to a unique process identifier (or pid), which is typically
an integer number.
When a process creates a subprocess, that subprocess
may be able to obtain its resources directly from the
operating system, or it may be constrained to a subset of
the resources of the parent process.
The parent may have to partition its resources among its
children, or it may be able to share some resources (such
as memory or files) among several of its children.
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.
Process Creation (Cont.)
UNIX examples
fork system call creates new process
Shared memory
Message passing
Operations
create a new mailbox
send and receive messages through mailbox
destroy a mailbox
Primitives are defined as:
send(A, message) – send a message to mailbox A
receive(A, message) – receive a message from
mailbox A
Synchronization