Question-1 Explain Process Model in brief
In this model, all the runnable software on the computer, sometimes including the operating system, is organized into a number of sequential processes.
- A process is just an executing program, including the current values of the program counter, registers, and variables.
- Conceptually, each process has its own virtual CPU.
- In reality, of course, the real CPU switches back and forth from process to process, but to understand the system, much easier to think about a collection of processes running in (pseudo) parallel, than to try to keep track of how the CPU switches from program to program.
- This rapid switching back and forth is called multiprogramming.
- In Fig. below (a) we see a computer multiprogramming four programs in memory.
- In Fig. below (b) we see four processes, each with its own flow of control (i.e., its own logical program counter), and each one running independently of the other ones.
- There is only one physical program counter, so when each process runs, its logical program counter is loaded into the real program counter.
- When it is finished for the time being, the physical program counter is saved in the process’ logical program counter in memory.
- In Fig. below (c) we see that over a long period of time interval, all the processes have made progress, but at any given instant only one process is actually running.
- With the CPU switching back and forth among the processes, the rate at which a process performs its computation will not be uniform and probably not even reproducible if the same processes are run again.
- Thus, processes must not be programmed with built-in assumptions about timing.
Figure (a) Multiprogramming of four programs. (b) Conceptual model of four independent, sequential processes. (c) Only one program is active at once.
There are four principal events that cause processes to be created:
- System initialization.
- Execution of a process creation system call by a running process.
- A user request to create a new process.
- Initiation of a batch job.
After a process has been created, it starts running and does whatever its job is.
However, nothing lasts forever, not even processes. Sooner or later the new process will terminate, usually due to one of the following conditions:
- Normal exit (voluntary).
- Error exit (voluntary).
- Fatal error (involuntary).
- Killed by another process (involuntary).
- In some systems, when a process creates another process, the parent process and child process continue to be associated in certain ways.
- The child process can itself create more processes, forming a process hierarchy.
- An example of process hierarchy is in UNIX, which initializes itself when it is started.
- A special process, called init, is present in the boot image.
- When it starts running, it reads a file telling how many terminals there are.
- Then it forks off one new process per terminal. These processes wait for someone to log in.
- If a login is successful, the login process executes a shell to accept commands. These commands may start up more processes, and so forth.
- Thus, all the processes in the whole system belong to a single tree, with init at the root.
- In contrast, Windows does not have any concept of a process hierarchy. All processes are equal.
- The only identification for parent child process is that when a process is created, the parent is given a special token (called a handle) that it can use to control the child.
- However, it is free to pass this token to some other process, thus invalidating the hierarchy. Processes in UNIX cannot disinherit their children.