zoukankan      html  css  js  c++  java
  • minix文件读写中使用的一个额外但是必须的结构filp表

    1.为什么需要他

    因为子进程与父进程之间需要共享文件读写指针。

    2.构成

    代码:

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                          servers/fs/file.h
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
     21700    /* This is the filp table.  It is an intermediary between file descriptors and
     21701     * inodes.  A slot is free if filp_count == 0.
     21702     */
     21703    
     21704    EXTERN struct filp {
     21705      mode_t filp_mode;             /* RW bits, telling how file is opened */
     21706      int filp_flags;               /* flags from open and fcntl */
     21707      int filp_count;               /* how many file descriptors share this slot?*/
     21708      struct inode *filp_ino;       /* pointer to the inode */
     21709      off_t filp_pos;               /* file position */
       File: Page: 928 servers/fs/file.h
     21710    
     21711      /* the following fields are for select() and are owned by the generic
     21712       * select() code (i.e., fd-type-specific select() code can't touch these).
     21713       */
     21714      int filp_selectors;           /* select()ing processes blocking on this fd */
     21715      int filp_select_ops;          /* interested in these SEL_* operations */
     21716    
     21717      /* following are for fd-type-specific select() */
     21718      int filp_pipe_select_ops;
     21719    } filp[NR_FILPS];
     21720    
     21721    #define FILP_CLOSED     0       /* filp_mode:  associated device closed */
     21722    
     21723    #define NIL_FILP (struct filp *) 0      /* indicates absence of a filp slot */

    filp真正必须包含的内容是共享文件的位置,但是实现时候将inode也放在里面。

    这么做的好处是,在进程表中的文件描述符数组只需要包含指向filp表项的指针。

  • 相关阅读:
    echarts
    联合省选2021游记
    高维 FWT 学习笔记
    Unicode简介
    mac安装brew
    原生JS实现分页跳转
    Kubernetes Pod Probes 探针解析
    Kubernetes Secrets
    Kubernetes Container lifecycle hooks
    个人作业1——四则运算题目生成程序(基于java)
  • 原文地址:https://www.cnblogs.com/jun14/p/2809999.html
Copyright © 2011-2022 走看看