A process is always in one of the many states. A state shows the current activity of a process. In a multitasking system, although to a user it appears that all processes are running simultaneously , strictly speaking only one process is active on one CPU at a time. The kernel schedules the processes such that every process gets a time slice for its execution. During the life cycle of a process, it changes its state many times.
A process is in a running state when its text (code) is being executed. The kernel schedules processes such that each process has its time slice during which the kernel executes its code. A process may go to another state from the running state depending on several factors.
A process may have to wait for a resource or event that is currently not available. It makes a sleep system call that puts the process on a queue of sleeping processes. This system call also changes the state of the process. When the resource becomes available, the kernel wakes up the process.
When the kernel wakes up a sleeping process, its state changes and becomes runnable. It means that the process becomes ready to run and waits for its scheduled time slice.
The stop signal puts a process in the stopped or suspended state. A stop signal changes the state of the process immediately. The process remains stopped until its gets a continue signal. After getting this signal, the stopped process goes into a runnable (or ready to run) state. If a process receives a stop signal when it is sleeping, it goes back to a sleep state after receiving a continue signal.
When a process terminates, it sends an exit system call. At this time, the kernel releases resources used by the process. The process becomes a zombie and remains in the zombie state until its parent process gives it permission to die. If the parent process is not responding, the process may be left in a zombie state indefinitely.
Top |