4.Process‎ > ‎

Process Operations


Process Creation

In general-purpose systems, some way is needed to create processes as needed during operation. There are four principal events led to processes creation.

  • System initialization.
  • Execution of a process Creation System calls by a running process.
  • A user request to create a new process.
  • Initialization of a batch job.
     

Foreground processes interact with users. Background processes that stay in background sleeping but suddenly springing to life to handle activity such as email, webpage, printing, and so on. Background processes are called daemons. This call creates an exact clone of the calling process.

A process may create a new process by some create process such as 'fork'. It choose to does so, creating process is called parent process and the created one is called the child processes. Only one parent is needed to create a child process. Note that unlike plants and animals that use sexual representation, a process has only one parent. This creation of process (processes) yields a hierarchical structure of processes like one in the figure. Notice that each child has only one parent but each parent may have many children. After the fork, the two processes, the parent and the child, have the same memory image, the same environment strings and the same open files. After a process is created, both the parent and child have their own distinct address space. If either process changes a word in its address space, the change is not visible to the other process.

                                        <Figure 3.2 pp.55 From Dietel>

Following are some reasons for creation of a process

  • User logs on.

  • User starts a program.

  • Operating systems creates process to provide service, e.g., to manage printer.

  • Some program starts another process, e.g., Netscape calls xv to display a picture.

Process Termination

A process terminates when it finishes executing its last statement. Its resources are returned to the system, it is purged from any system lists or tables, and its process control block (PCB) is erased i.e., the PCB's memory space is returned to a free memory pool. The new process terminates the existing process, usually due to following reasons:

  • Normal Exist    Most processes terminates because they have done their job. This call is exist in UNIX.
  • Error Exist    When process discovers a fatal error. For example, a user tries to compile a program that does not exist.
  • Fatal Error    An error caused by process due to a bug in program for example, executing an illegal instruction, referring non-existing memory or dividing by zero.
  • Killed by another Process    A process executes a system call telling the Operating Systems to terminate some other process. In UNIX, this call is kill. In some systems when a process kills all processes it created are killed as well (UNIX does not work this way).

Process States

A process goes through a series of discrete process states.

  • New State    The process being created.
  • Terminated State    The process has finished execution.
  • Blocked (waiting) State    When a process blocks, it does so because logically it cannot continue, typically because it is waiting for input that is not yet available. Formally, a process is said to be blocked if it is waiting for some event to happen (such as an I/O completion) before it can proceed. In this state a process is unable to run until some external event happens.
  • Running State    A process is said t be running if it currently has the CPU, that is, actually using the CPU at that particular instant.
  • Ready State    A process is said to be ready if it use a CPU if one were available. It is runable but temporarily stopped to let another process run.

Logically, the 'Running' and 'Ready' states are similar. In both cases the process is willing to run, only in the case of 'Ready' state, there is temporarily no CPU available for it. The 'Blocked' state is different from the 'Running' and 'Ready' states in that the process cannot run, even if the CPU is available.

Comments