Chinaunix首页 | 论坛 | 博客
  • 博客访问: 591204
  • 博文数量: 68
  • 博客积分: 2621
  • 博客等级: 少校
  • 技术积分: 1498
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-23 21:04
文章分类

全部博文(68)

文章存档

2013年(8)

2012年(52)

2010年(8)

分类: LINUX

2012-02-20 09:18:46

  阅读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

阅读(8805) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~