Os Lec 4 Process
Os Lec 4 Process
PROCESSES
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.
Scenario-2: Scientist's son comes running in crying, saying he has been stung by a bee.
Scientist records where he - the state of running process was in the recipe saved
Reach first aid book and materials - Another process fetched
Follow the first aid action - Processor switched for new (high priority job) process
On completion of aid, cake - Completion of high priority baking starts again from job & return
back to the last one where it was left
A process is an activity of some kind, it has program, input, output and state.
Process Models
Uniprogramming
Multiprogramming
Multiprocessing
Uniprogramming
Only one process at a time.
Two common techniques for loading executable files are double-clicking an icon representing
the
executable file and entering the name of the executable file on the command line (as in prog. exe
or a.
out.)
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 (such as an I/O completion or
reception of a signal).
• Ready. The process is waiting to be assigned to a processor.
• Terminated. The process has finished execution.
These names are arbitrary, and they vary across operating systems. The states that they represent
are footing on all systems, however. Certain operating systems also more finely delineate process
states. It is important to realize that only one process can be running on any processor at any
instant
Operations on Processes
The processes in the system can execute concurrently, and they must be created and
deleted dynamically. OS provide the mechanism for process creation and termination.
Process Creation.
Process Termination.
Process Creation
There are four principal events that cause the process to be created:
System initialization.
Execution of a process creation system call.
User request to create a new process.
Initiation of a batch job.
A process may create several new processes during the course of execution. The creating process
is called a parent process, where as the new processes are called children of that process
return 0;
}
Process Termination
Process are terminated on the following conditions
1. Normal exit.
2. Error exit.
3. Fatal error.
4. Killed by another process.
Example:
In Unix the normal exit is done by calling a exit system call. The process return data (output) to
its parent process via the wait system call. kill system call is used to kill other process