@oraccha

Lions’ Commentary on UNIX     2011
             2011   10   16
•1

  •2         10:30                            Prezi



  •
         ←
http://prezi.com/zm2fff4l-ia1/data-structure-of-the-unix-v6/
user file
                                                                                       descriptor table                   file table                   inode table
                                                                                       0
                                                                                                              file[100] inode[100]                                                     fd -> inode
                                                                                                                                                   am^/etc/passwd)
                                                                                                                        count      D
                                                                                                                          j        Read




                                                                                       u_ofile[15]                   „
                                                                                                                    k
                                                                                                                        0011111
                                                                                                                                  «J     ,


                   inode -> Disk
4.2                     STRUCTURE OF A REGULAR FILE                           69                                          j       Rd-Wrf


                                                                                                                                                   ^             (local)


                                                                                                                                  f_inode
                                                                      Data
      Inode                                                          Blocks

      direct „
                                                    (buffers[])
                                                                                                                                  1
                                                                                                                    i count
                                                                                                                    1
                                                                                                                                 1
                                                                                                                        i   Write
      direct




                                                                                                          Figure 5.3. Data Structures after Open



                         i_addr[8]                                                 fdl - open("/etc/passwd", OJRDONLY);
                                                                                   fd2 - open ("local", 0_RDWR);
                                                                                                                         28
                                                                                                                                                       Process -> memory
                                                                                                                                                                 INTRODUCTION TO THE KERNEL

      direct ,                                                                     fd3 - open ("/etc/passwd", OJWRONLY);
                                                                                                                                                                                     per process
                                                                              Figure 5.3 shows the relationship between the inode table, file table, and user file
      direct                                                                  descriptor data structures. Bach open returns a file descriptor to the process, and
                                                                              the corresponding entry in the user file descriptor table points to a unique entry in
      direct,


      direct                                                                       programmers to encode only two parameters.
                                                                                                                                                 u_procp
                                                                                   does not check the third parameter unless the second parameter indicates that it must, allowing



                                                                                                                                             proc[50]
               8

      direct,

       single
      indirect                                                                                                                                                  p_addr?
      double
      indirect


                                                                                                                                                                        coremap[100]?
       triple
      indirect




                   Figure 4.6. Direct and Indirect Blocks in Inode
User Program

User level                   trap                      Libraries (libc)


                              System call interface

                                                Process
               File system                                           IPC
                                                control
                                               subsystem
                  Buffer cache                                   Scheduler

          char      block                                         Memory
          Device drivers                                           mng.


Kernel level                        Hardware control

Hardware level
                                    Hardware
                                                                           Bach
User Program

User level                   trap                      Libraries (libc)


                              System call interface
                                          Section 1
                                          (                                )
                                                Process
               File system                                           IPC
                                                control
                                               subsystem
                  Buffer cache                                   Scheduler

          char      block                                         Memory
          Device drivers                                           mng.


Kernel level                        Hardware control

Hardware level
                                    Hardware
                                                                           Bach
User Program
     Section 2
User level                   trap                      Libraries (libc)


                              System call interface

                                                Process
               File system                                           IPC
                                                control
                                               subsystem
                  Buffer cache                                   Scheduler

          char      block                                         Memory
          Device drivers                                           mng.


Kernel level                        Hardware control

Hardware level
                                    Hardware
                                                                           Bach
User Program

User level                   trap                      Libraries (libc)


                              System call interface

                                                Process
               File system                                           IPC
                                                control
                              Section 3        subsystem
                  Buffer cache                                   Scheduler

          char      block                                         Memory
          Device drivers                                           mng.


Kernel level                        Hardware control

Hardware level
                                    Hardware
                                                                           Bach
User Program

User level                   trap                      Libraries (libc)


                              System call interface
                    Section 4
                                                Process
               File system                                           IPC
                                                control
                                               subsystem
                  Buffer cache                                   Scheduler

          char      block                                         Memory
          Device drivers                                           mng.


Kernel level                        Hardware control

Hardware level
                                    Hardware
                                                                           Bach
User Program

User level                   trap                      Libraries (libc)


                              System call interface

                                                Process
               File system                                           IPC
                                                control
   Section 5                                   subsystem
                  Buffer cache                                   Scheduler

          char      block                                         Memory
          Device drivers                                           mng.


Kernel level                        Hardware control

Hardware level
                                    Hardware
                                                                           Bach
162 THE STRUCTURE OF PROCESSES




Figure 6.1. Process State Transition Diagram
3.4

4720
       512   514

Lions本読書会合宿成果発表

  • 1.
    @oraccha Lions’ Commentary onUNIX 2011 2011 10 16
  • 2.
    •1 •2 10:30 Prezi • ← http://prezi.com/zm2fff4l-ia1/data-structure-of-the-unix-v6/
  • 3.
    user file descriptor table file table inode table 0 file[100] inode[100] fd -> inode am^/etc/passwd) count D j Read u_ofile[15] „ k 0011111 «J , inode -> Disk 4.2 STRUCTURE OF A REGULAR FILE 69 j Rd-Wrf ^ (local) f_inode Data Inode Blocks direct „ (buffers[]) 1 i count 1 1 i Write direct Figure 5.3. Data Structures after Open i_addr[8] fdl - open("/etc/passwd", OJRDONLY); fd2 - open ("local", 0_RDWR); 28 Process -> memory INTRODUCTION TO THE KERNEL direct , fd3 - open ("/etc/passwd", OJWRONLY); per process Figure 5.3 shows the relationship between the inode table, file table, and user file direct descriptor data structures. Bach open returns a file descriptor to the process, and the corresponding entry in the user file descriptor table points to a unique entry in direct, direct programmers to encode only two parameters. u_procp does not check the third parameter unless the second parameter indicates that it must, allowing proc[50] 8 direct, single indirect p_addr? double indirect coremap[100]? triple indirect Figure 4.6. Direct and Indirect Blocks in Inode
  • 4.
    User Program User level trap Libraries (libc) System call interface Process File system IPC control subsystem Buffer cache Scheduler char block Memory Device drivers mng. Kernel level Hardware control Hardware level Hardware Bach
  • 5.
    User Program User level trap Libraries (libc) System call interface Section 1 ( ) Process File system IPC control subsystem Buffer cache Scheduler char block Memory Device drivers mng. Kernel level Hardware control Hardware level Hardware Bach
  • 6.
    User Program Section 2 User level trap Libraries (libc) System call interface Process File system IPC control subsystem Buffer cache Scheduler char block Memory Device drivers mng. Kernel level Hardware control Hardware level Hardware Bach
  • 7.
    User Program User level trap Libraries (libc) System call interface Process File system IPC control Section 3 subsystem Buffer cache Scheduler char block Memory Device drivers mng. Kernel level Hardware control Hardware level Hardware Bach
  • 8.
    User Program User level trap Libraries (libc) System call interface Section 4 Process File system IPC control subsystem Buffer cache Scheduler char block Memory Device drivers mng. Kernel level Hardware control Hardware level Hardware Bach
  • 9.
    User Program User level trap Libraries (libc) System call interface Process File system IPC control Section 5 subsystem Buffer cache Scheduler char block Memory Device drivers mng. Kernel level Hardware control Hardware level Hardware Bach
  • 10.
    162 THE STRUCTUREOF PROCESSES Figure 6.1. Process State Transition Diagram
  • 11.
    3.4 4720 512 514