0% found this document useful (0 votes)
24 views

Unix&Network Programming: Study of Multiuser Operating System and Their Features"

This document discusses file sharing in Unix systems. It describes the three main data structures used by the kernel to represent open files and shared access among processes: 1) the process table, which contains file descriptors for each open file, 2) the file table, which contains per-file information like access modes and file offsets, and 3) the v-node table, which links each open file to its inode containing metadata like owner and size. These data structures allow multiple processes to independently access shared files using separate file table entries while mapping to a single v-node and inode representation on disk.

Uploaded by

imadpr
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Unix&Network Programming: Study of Multiuser Operating System and Their Features"

This document discusses file sharing in Unix systems. It describes the three main data structures used by the kernel to represent open files and shared access among processes: 1) the process table, which contains file descriptors for each open file, 2) the file table, which contains per-file information like access modes and file offsets, and 3) the v-node table, which links each open file to its inode containing metadata like owner and size. These data structures allow multiple processes to independently access shared files using separate file table entries while mapping to a single v-node and inode representation on disk.

Uploaded by

imadpr
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 8

Unix&Network programming

" Study Of Multiuser Operating System and their Features

Course Instructor University

: K.JAVUBAR SATHICK : BSA University

Ihr Logo

File sharing
The unix system supports the sharing of open files among different

processes.
The kernel uses 3 data structures(ds) to represent an open file and the

relationship among them to check out the influence factor of one process with the other.
The three d.s are

1. Process table 2. File table & 3.V-node table

DEPARTMENT OF COMPUTER APPLICATIONS

Your Logo

File sharing-Kernel ds for open files


File table Process table entry File status flags Current file offset V-node pointer V-node table V-node information i-node information Current file size

fd flag fptr

Fd0
Fd1 Fd2 File status flags Current file offset V-node pointer

. ..

V-node information i-node information Current file size

DEPARTMENT OF COMPUTER APPLICATIONS

Your Logo

File sharing-Kernels data structure


1. Process table: Every process has an entry in the process table Within each process table entry is a table of open file descriptor. And fd has file descriptor flag and ptr to file table entry.

2. File table:
kernel maintains the file table for all open files. File table entry contains (a) file status flag which keeps track file whether

file is in read, write,seek state etc.. Respectively. (b) Current file offset which specifies initial position file pointer. (c) A pointer to the v-node table entry for the file.

DEPARTMENT OF COMPUTER APPLICATIONS

Your Logo

File sharing-Kernels data structure


3. V-node table:
Each open file has a v-node structure that contains information about the

type of file(tof) and ptrs to functions that operate on file.


For most files,the v-node also contains the i-node for the file. i-node contains the owner of the file, size of the file, information regarding

changes happened to the open file(updated info and current file status after modification)

DEPARTMENT OF COMPUTER APPLICATIONS

Your Logo

File sharing-Two indepedent processes with same file open.


File sharing among two indepedent processes have the same file open,we

could have the arrangements as shown diagram in the following slide.


We assume that the first process p1 has the file open on descriptor3. And the second process p2 has the file open on descriptor4. Each process that opens the file gets its own file table entry.

But, only single v-node table entry is required for a given file.
One reason for the above criteria is each process gets its own file table

entry is because each process has its own current file offset for the file.

DEPARTMENT OF COMPUTER APPLICATIONS

Your Logo

File sharing-Two indepedent processes with same file open.


File table entry Process table entry
Fdflg fptr

V-node table entry V-node information i-node information Current file size

Fd0 P1 Fd1 Fd2 Fd3

File status flags Current file offset V-node pointer

p2 Fd0
Fd1 Fd2 Fd3 Fd4

Fdflg fptr

File status flags Current file offset V-node pointer

DEPARTMENT OF COMPUTER APPLICATIONS

Your Logo

File sharing-Two indepedent processes with same file open.


Given these ds, we now need to be more specific about what happens

when certain operations implemented on to the open file. Operations like read,write,seek etc...
After each write operation is complete, the current file offset in the file

table entry is incremented by no. Of bytes written. If this causes the current file offset to exceed the current file size, then the current file size in the i-node table entry is set current file offset(for eg, the file is extended).
If a file is opened with the O_append flag, a corresponding flag is set

in the file status flag of the file table entry.


Each time write is performed for a file with this append flag set, the

current file offset in the file table entry is first set to the current file size from i-node entry. This forces every write operation to restrict within available current file size and it reaches the current end of file.
Your Logo

DEPARTMENT OF COMPUTER APPLICATIONS

You might also like