ptg10805159Section 14.3 RecordLocking 493
Figure14.8 shows the resulting data structures after both the parent and the child have
paused.parent process table entry...
fd1:
fd2:
fd3:flagsfd pointerfilechild process table entry...
fd1:
fd2:
fd3:flagsfd pointerfilefile status flags
current file offset
v-node pointerfile status flags
current file offset
v-node pointerfile table entryfile table entryv-node information
lockfpointer
v_datai-node information
current file size
i_vnodev-node table entryi-nodelock headerlockf_entrylistlink
flags
starting offset
ending offset
lock_ownerpointerlink
flags
starting offset
ending offset
lock_ownerpointerowner informationparent process IDowner informationchild process IDstruct lockfstruct lockf_entry struct lockf_entrystruct lock_owner struct lock_ownerFigure 14.8 The FreeBSD data structures for recordlockingWe’ve shown the data structures that result from theopen,fork,anddupcalls
earlier (Figures 3.9 and 8.2). What is new hereare thelockfstructures that arelinked
together from the i-node structure. Eachlockfstructuredescribes one locked region
(defined by an offset and length) for a given process. Weshow two of these structures:
one for the parent’s call towrite_lockand one for the child’s call toread_lock.
Each structurecontains the corresponding process ID.
In the parent, closing any one offd1,fd2,orfd3causes the parent’s lock to be
released. When any one of these three file descriptors is closed, the kernel goes through