How Linux utilizes processes, calls them, and then also utilize states and eventually end processes

How Linux utilizes processes, calls them, and then also utilize states and eventually end processes

A process initially is a program on disk, 'hanging around' and 'doing nothing'. It is not until it is loaded into the address space that it begins executing (Arpaci-Dusseau et al, 2018). Once loaded, memory is allocated for the program's run-time stack and some memory may be allocated for the heap. After I/O related initialization tasks are performed, the program starts running (Arpaci-Dusseau et al 2018).?

In Linux [which is a UNIX based system], system calls are used for process creation. These system calls include: fork(), wait(), and exec().

fork()

When called creates a new process, returning to the parent the child's PID and zero to the new child -- if successful. Otherwise it returns -1 and no child is `born`. However, it is "non-deterministic" as you cannot tell who will run first, the parent or the child (Arpaci-Dusseau et al, 2018). To try and solve this,?wait ()?is used concurrently.

wait()

This system call introduces determinism, that is, it is clear who runs, rather returns first. The child is allowed to execute completely before the parent can return.?

exec()

Used when you want to execute a different program from the calling program (Arpaci-Dusseauet al, 2018). On success, it does not return.

exit()

After executing, a process can call the?exit()?system call?to terminate. In this case, the resources that this process was using are released and given to other needing processes (magichat, 2022).

In Linux, a process can be: running, in the queue to be run, or waiting. If a process is running, it is said to be in the RUNNING state; if a process is in the queue to run it is said to be RUNNABLE; if a process is waiting on something, it is either in the S [INTERRRUPTABLE_SLEEP] or D [UNINTERRUPTABLE_SLEEP] state (Chapman, 2021).

Processes oscillates between this states and eventually terminate. When a process terminates its resources are given to other processes. Thus, each process is given a chance to run/execute.


References

?Arpaci-Dusseau,?R.?H., & Arpaci-Dusseau,?A.?C. (2018).?Operating systems: three easy pieces?(1.01?ed.).?Arpaci-Dusseau Books.?https://pages.cs.wisc.edu/~remzi/OSTEP/

magichat. (2022, June 8).?Linux system call in detail. GeeksforGeeks.?https://www.geeksforgeeks.org/linux-system-call-in-detail/

Chapman,?D. (2021, December 9).?What are the 5 linux process states??CBTnuggets.?https://www.cbtnuggets.com/blog/certifications/open-source/what-are-the-5-linux-process-states

要查看或添加评论,请登录

Ouma Winnie的更多文章

社区洞察

其他会员也浏览了