进程的文件,mm_struct和files_struct中文件之间的关系?

sli*_*ter 5 c linux kernel

在task_struct中,我们可以找到:

struct mm_struct *mm, *active_mm;
struct files_struct *files;  
Run Code Online (Sandbox Code Playgroud)

files_struct包含指向最多256个文件数据结构的指针,每个文件数据结构描述此进程正在使用的文件.

struct file * fd_array[NR_OPEN_DEFAULT];
Run Code Online (Sandbox Code Playgroud)

mm_struct包含vm_area_struct.

struct vm_area_struct * mmap;           /* list of VMAs */
Run Code Online (Sandbox Code Playgroud)

在vm_area_struct中,我们可以找到:

struct file * vm_file;          /* File we map to (can be NULL). */
Run Code Online (Sandbox Code Playgroud)

所以我的问题是:

  1. fd_array和vm_file中的文件之间有什么关系?

  2. fd_array中显示的所有文件是否也将以与图片中所示类似的方式映射到vm_area_struct中?或者,vm_area_struct中映射的所有文件是否都会显示在fd_array中?

谢谢,

一只忙碌的猫http://static.duartes.org/img/blogPosts/memoryDe​​scriptorAndMemoryAreas.png

caf*_*caf 1

中的文件fd_array是当前具有与其关联的文件描述符的文件(例如,使用open()socket()类似打开的文件),而由 VMA 链接的文件是映射到进程内存的文件(例如,使用mmap())。文件可以属于任一类别或同时属于两个类别,因此 中的这些文件fd_array不一定由 VMA 链接,反之亦然。