As we learned in chapter 11 shared data must be

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: gs, the current file position and a reference count of the number of descriptor entries that currently point to it. The file table entry in turn points to an i-node table entry that characterizes the physical location of the file on disk, and contains most of the information in the stat structure, including the st mode and st size members. 12.4. UNIX FILE I/O 627 Typically there is a one-to-one mapping between descriptors and files. For example, suppose we have the situation in Figure 12.20 where descriptor 1 (stdout) corresponds to file (say a terminal), while descriptor 4 corresponds to file (say a disk). The reference counts for the and are both equal to 1. open file table entries file A file pos refcnt = 1 ... file B file B file pos refcnt = 1 ... ... st_mode st_size i-node table entries file A per process descriptor table 0 1 2 3 4 5 6 7 ... st_mode st_size Figure 12.20: Kernel data structures before dup2(4,1) The dup2 function allows multiple descriptors to be associated with the same file. For example, Figure 12.21 shows the situat...
View Full Document

Ask a homework question - tutors are online