Re: [LIP] Re: Re: confusion about half-duplex pipes.

"Yogesh Kulkarni" <Yogesh.Kulkarni-oonXi/[email protected]>
Newsgroups gmane.user-groups.linux.india.programmers
Message-ID <OF194E188D.A6379CEC-ON65256DDD.00244C64-65256DDD.0025CC8B@lntinfotech.com>




| Another thing, that means that the file table entries
| for the descriptors are different for both the parent
| and child.But they point to the same vnode.

Hi,


In modern unix systems, fork() follows COW ie copy on write mechanisms.
Usually fork() is immediately followed by exec() to execute a new process.
So if u copy the address space in fork and then immediately discard it,
it's
not the smartest thing to do. Hence whenever the child attempts to write
something
in the address space, only then the address space gets copied. This process
is COW.

As far as vnodes are concerned u hit the nail on the head. Each file is
represented
ony by one vnode, irrespective of the number of process accessing each
file.
The number of process that have issued an "open" of the file is maintained
in the vnode
as refrence count. Each process has a pointer to a struct file which
contains pointers
to the files. When u open a file, u get a small integer which is an offset
in this per
process table/list. The information of the current read offset, read flags,
open flags
is maintained in this structure. Thus each process has a track of its own
parameters,
while the kernel has the track through reference count.

I hope that this will help clear ur doubts. I am not exactly sure of the
linux implementation
If u need all the details u can always refer Uresh Wahalaya's Modern Unix
OS or
Berny Goodhart's Magic Garden explained.

--Yogesh.









-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.