I wanna know indepth about the COW implementation of
fork() in Linux 2.4 and higher - all including page
table stuff..

Oh, and a quickie :

When we print an address of a variable, is it the
virtual address or the physical one which is printed ?

        printf("%04X", &i); /* Is virtual address of 'i'
printed or the physical one ?*/

Methinks it's the virtual address as from the page
table. Am I right ?

If you didn't get it, or think I am on dope, consider
this :

#include <stdio.h>

int main()
{
        int i = 5, pid, count, *p = &i;

        char choice[4] = {0};

        printf("\ni = %d (%X)\n", i, &i);

        printf("\nFork ?\n");

        scanf("%s", choice);
        
        if(choice[0] == 'y')
        {
                pid = fork();

                if(pid < 0)
                {
                        printf("\nfork() failed\n");
                }
                else if(pid == 0)
                {
                        i = 6;
                        printf("\nChild : %d (%X)\n", i, &i);
                }
                else
                {
                        printf("\n[1]Spawned child pid = %d, i = %d
(%X)\n", pid, i, &i);
                        wait(0);
                        printf("\n[2]Spawned child pid = %d, i = %d
(%X)\n", pid, i, &i);
                        printf("\nDone waiting for child\n");
                }
        
                printf("{%d} ", pid);
        
                for(count = 0; count < 10; ++count, --p) printf("%x
", *p);
        
                printf("\n{%d}i : %d (%X)\n", pid, i, &i);
        }
        
        return 0;
}

Look at it closely, and match it with the output. Who
can explain that to me ?

PS: Hmmm.. last few days, before trolling started
AGAIN, there was talk about a technically oriented
group starting up ?
I rolled my eyes then, but given the present scenario
of immense trolls/spam/whatnot filling up my mailbox,
maybe that was a better idea ?

Regards

Subhobroto Sinha
http://www.geocities.com/subhobrotosinha


                
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


--
To unsubscribe, send mail to [EMAIL PROTECTED] with the body
"unsubscribe ilug-cal" and an empty subject line.
FAQ: http://www.ilug-cal.org/node.php?id=3

Reply via email to