[PLUG] Weird Output of a C program in Linux
Ashutosh Adkar
ashu.adkar at gmail.com
Wed Jul 18 21:39:28 IST 2007
On 7/18/07, yogesh tillu <yogesh_tillu2003 at yahoo.co.in> wrote:
>
>
>
> Aditya Godbole <aag.lists at gmail.com> wrote: On 7/17/07, Pranav Peshwe
> wrote:
>
> >
> > IMHO, it does send the data to the buffer. Due to the fork, the new
> > task(child) gets a copy of the buffer (which already contains the 'Hello
> > World!' string). This(fork()) is where the duplication occurs. Further
> > printfs in the two tasks lead to flushing of their respective buffers to
> the
> > console. With a '\n' after 'Hello World!', the child would get an empty
> > buffer to begin with.
> >
>
> Yeah, thats right. The buffer is filled but not flushed. After the
> fork, the entire address space (and hence the buffer) gets replicated
> * But I think currently copy on write approach is used for the
> *implementation of the fork .So entire address space will not get
> *replicated {previously clone approach was used , so in that *whole address
> space gets replicated }
> *
> and is flushed after the second the printf in both processes.
>
> -aditya
>
>
> cheers,
> yogesh
Yes.Thats right.But isnt the buffer in the user area.Which is copied as
is, except for the pointer to the proc structure.
---------------------------------
> 5, 50, 500, 5000. Store N number of mails in your inbox. Click here.
> --
> ______________________________________________________________________
> Pune GNU/Linux Users Group Mailing List: (plug-mail at plug.org.in)
> List Information: http://plug.org.in/cgi-bin/mailman/listinfo/plug-mail
> Send 'help' to plug-mail-request at plug.org.in for mailing instructions.
>
--
Regards,
Ashutosh Adkar
More information about the Plug-mail
mailing list