Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3462362
  • 博文数量: 1450
  • 博客积分: 11163
  • 博客等级: 上将
  • 技术积分: 11101
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-25 14:40
文章分类

全部博文(1450)

文章存档

2017年(5)

2014年(2)

2013年(3)

2012年(35)

2011年(39)

2010年(88)

2009年(395)

2008年(382)

2007年(241)

2006年(246)

2005年(14)

分类: LINUX

2006-06-07 18:16:45

The kernel uses three data structures to represent an open file, and the relationships among them determine the effect one process has on another with regard to file sharing.

  1. Every process has an entry in the process table. Within each process table entry is a table of open file descriptors, which we can think of as a vector, with one entry per descriptor. Associated with each file descriptor are

    1. The file descriptor flags (close-on-exec; refer to Figure 3.6 and Section 3.14)

    2. A pointer to a file table entry

  2. The kernel maintains a file table for all open files. Each file table entry contains

    1. The file status flags for the file, such as read, write, append, sync, and nonblocking; more on these in Section 3.14

    2. The current file offset

    3. A pointer to the v-node table entry for the file

  3. Each open file (or device) has a v-node structure that contains information about the type of file and pointers to functions that operate on the file. For most files, the v-node also contains the i-node for the file. This information is read from disk when the file is opened, so that all the pertinent information about the file is readily available. For example, the i-node contains the owner of the file, the size of the file, pointers to where the actual data blocks for the file are located on disk, and so on. (We talk more about i-nodes in Section 4.14 when we describe the typical UNIX file system in more detail.)

    Linux has no v-node. Instead, a generic i-node structure is used. Although the implementations differ, the v-node is conceptually the same as a generic i-node. Both point to an i-node structure specific to the file system.

  4. Figure 3.6. Kernel data structures for open files

 
Figure 3.7. Two independent processes with the same file open


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