File System Information

Table of contents:

In addition to process ID information, the process environment contains file system information. Associated with each open file is an integer file descriptor value that the operating system uses as an index to a 1,024-entry file descriptor table located in the u ( user ) area for the process. The per-process file descriptor table references a system file table , which is located in kernel space. In turn , the system file table maps to a system inode table that contains a reference to a more complete internal description of the file.

When a child process is generated, it receives a copy of its parent's file descriptor table (this includes the three descriptors stdin , stdout , and stderr ) with the file pointer offset associated with each open file. If a file is marked as shareable, the operating system will need to save each file pointer offset separately. The relationship of process and system tables are shown in Figure 2.10.

Figure 2.10. Process/system file table relationships.

graphics/02fig10.gif

EXERCISE

Write a program that verifies that a parent and child process share the same file pointer and file pointer offset. The parent should open a text file and fork a child process. The child process should read from the text file and display what it has read. When the child terminates, the parent process should then read from the same file and display what it has read. At this stage, you may need to use the sleep system call to synchronize file access between the parent and child processes.

EXERCISE

Write a program that determines by trial and error the number of files a process can have simultaneously open (is it really 1,024, as mentioned?). Be sure to remove (investigate the unlink system call) any files that you generate.

Programs and Processes

Processing Environment

Using Processes

Primitive Communications

Pipes

Message Queues

Semaphores

Shared Memory

Remote Procedure Calls

Sockets

Threads

Appendix A. Using Linux Manual Pages

Appendix B. UNIX Error Messages

Appendix C. RPC Syntax Diagrams

Appendix D. Profiling Programs



Interprocess Communication in Linux
Interprocess Communications in Linux: The Nooks and Crannies
ISBN: 0130460427
EAN: 2147483647
Year: 2001
Pages: 136

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net