Linux进程
字符数量统计: 4358
fork这个单词在英文中原义是分岔,例如河流、道路一分为二的分岔口,作为物品则有叉子、耙子的意思。
a place where a road, river, etc. divides into two parts, or either of those two parts.
了解这一层英文含义更以利于我们理解fork()这个系统调用的作用:将进程一分为二,复制出一份完全相同的新进程,并作为原进程的子进程。
以下是fork()系统调用在man手册中的标准定义:
fork() creates a new process by duplicating the calling process. The new process is referred to as the child process. The calling process is referred to as the parent process.
在仅使用fork的情况下,一个常见的面试问题是:给你一段代码,分析执行后一共有多少个进程。
The exec() family of functions replaces the current process image with a new process image. The functions described in this manual page are layered on top of execve(2). (See the manual page for execve(2) for further details about the replacement of the current process image.)
The pthread_create() function starts a new thread in the calling process. The new thread starts execution by invoking start_routine(); arg is passed as the sole argument of start_routine().
通过pthread_setaffinity_np()函数来设置线程的CPU亲和性。
若你早與他人兩心同 何苦惹我錯付了情衷