官术网_书友最值得收藏!

  • Go Systems Programming
  • Mihalis Tsoukalos
  • 317字
  • 2021-07-02 18:07:55

The various states of a Unix process

Strictly speaking, a process is an execution environment that contains instructions, user-data and system-data parts, and other kinds of resources that are obtained during runtime. A program is a file that contains instructions and data, which are used for initializing the instruction and user-data parts of a process.

Back when the Unix operating system was first introduced, computers had single CPUs without multiple cores and a small amount of RAM. However, Unix was a multiuser and multitasking operating system. In order to actually be a multiuser and do multitasking, it had to be able to run each individual process sporadically, which means that a process should have multiple states. The following figure shows the possible states of a process as well as the right path to go from one state to another:

The states of a Unix process

There are three categories of processes: user processes, Kernel processes, and Daemon processes:

  • User processes run in user space and usually have no special access rights
  • Kernel processes are being executed in kernel space only and can fully access all kernel data structures
  • Daemon processes are programs that can be found in the user space and run in the background without the need for a Terminal

Realizing that you cannot control the state of a process is really important, as this is the job of the scheduler of the operating system that runs in the kernel. Putting it simply, you cannot tell when the state of a process is going to change or when the process is going to go into the running state, so your code cannot count on any such assumptions!

The C way for creating new processes involves the calling of the fork() system call. The return value of fork() allows the programmer to differentiate between the parent and child processes. However, Go does not support a similar functionality.
主站蜘蛛池模板: 岱山县| 定西市| 合山市| 壤塘县| 阳泉市| 乡城县| 淳安县| 罗甸县| 盘锦市| 宣威市| 治多县| 长兴县| 那坡县| 贡嘎县| 韩城市| 许昌县| 万山特区| 专栏| 奉化市| 鄂尔多斯市| 理塘县| 耒阳市| 南靖县| 福建省| 凤阳县| 大洼县| 临沧市| 永福县| 东平县| 托克托县| 连江县| 布尔津县| 大关县| 锦州市| 府谷县| 永城市| 阿拉尔市| 岳阳市| 和田县| 崇仁县| 子洲县|