<a href="http://blog.chinaunix.net/uid-24807808-id-3077199.html">NR_OPEN 與 NR_FILE 的差別</a>
閱讀0.11版的核心源碼時,在linux-0.11/fs/pipe.c中,函數sys_pipe()裡面出現了2個宏定義,NR_OPEN 與 NR_FILE。下面說明一下它們的差別:
1. NR_OPEN is the maximum number of files that can be opened by process。
NR_OPEN是一個程序可以打開的最大檔案數。
A process cannot use more than NR_OPEN file descriptors.
一個程序不能使用超過NR_OPEN檔案描述符。
The kernel also enforces a dynamic bound on the maximum number of file descriptors in the signal-<rlim[RLIMIT_NOFILE] structure of the process descriptor; this value is usually 1,024, but it can be raised if the process has root privileges.
2. NR_FILE is the limit on total number of files in the system at any given point in time
NR_FILE 是系統在某一給定時刻,限制的檔案總數
While initializing the kernel we setup the vfs cache with
start_kernel
vfs_caches_init(num_physpages);
files_init(mempages);
fs/file_table.c says
/* One file with associated inode and dcache is very roughly 1K.
* Per default don't use more than 10% of our memory for files.
n = (mempages * (PAGE_SIZE / 1024)) / 10;
this n can never be greater than NR_FILE
原文
<a href="http://blog.chinaunix.net/uid-24807808-id-3077199.html">http://blog.chinaunix.net/uid-24807808-id-3077199.html</a>