Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1916674
  • 博文数量: 498
  • 博客积分: 2078
  • 博客等级: 大尉
  • 技术积分: 1645
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-18 22:43
个人简介

安大

文章分类

全部博文(498)

文章存档

2017年(1)

2016年(2)

2015年(21)

2014年(90)

2013年(101)

2012年(267)

2011年(16)

分类: LINUX

2015-12-10 14:41:26

原文地址:NR_OPEN 与 NR_FILE 的区别 作者:licong0527

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

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