Linux内核进程限制

时间:2014-10-10 13:41:04

标签: recursion process linux-kernel

有人可以解释一下linux内核如何处理一个不断膨胀的进程队列吗?

我正在实现一个递归的fibonacci程序,用于fib(n)产生3个进程:

添加(fd1,fd2)

fib(n-1)(标准输出到fd1)

& fib(n-2)(stdout piped to fd2)

基础案例当然......

但是当n接近20左右时,我的一些fork()s正在提高errno 11并且fib没有返回正确的值

来自〜$ man fork

   EAGAIN fork() cannot allocate sufficient memory to copy the parent's page tables and allocate a task structure for the child.

   EAGAIN It was not possible to create a new process because the caller's RLIMIT_NPROC  resource  limit  was  encountered.   To
          exceed this limit, the process must have either the CAP_SYS_ADMIN or the CAP_SYS_RESOURCE capability.

如果我实现了一个跳转语句,以便在发生此错误时再次尝试fork(),那么该进程最终会以fib(~20)的正确值终止

我明白如果我做了fib(700),它可能不会终止,但我对fork()系统调用开始引发此错误的边缘发生的事情感兴趣。

0 个答案:

没有答案
相关问题