Re: [algogeeks] Re: question on fork()

2011-08-24 Thread shashi kant
6 red 10 greens On Wed, Aug 24, 2011 at 9:25 AM, Ankuj Gupta wrote: > how can be there 20 greens ? > > On Aug 24, 12:12 am, DK wrote: > > The standard library is neither multithread safe nor multiprocess safe. > > If you want the correct answer, use shared memory and maintain a shared > > cou

Re: [algogeeks] Re: question on fork()

2011-08-23 Thread Prem Krishna Chettri
I Can See 10 Green and 10 Red Process.. Can Someone Compile to verify this... Prem On Tue, Aug 23, 2011 at 1:24 AM, gmagog...@gmail.com wrote: > Infinite times > Yanan Cao > > > > On Mon, Aug 22, 2011 at 2:43 PM, Don wrote: > >> // DO NOT RUN THIS! By inspection, how many times will it print "H

Re: [algogeeks] Re: question on fork()

2011-08-22 Thread gmagog...@gmail.com
Infinite times Yanan Cao On Mon, Aug 22, 2011 at 2:43 PM, Don wrote: > // DO NOT RUN THIS! By inspection, how many times will it print "Hello > world"? > // If you find out by running it, that is cheating. Don't do it! > int main() > { > int i=0, j=0; > for(i = 0; i*j < 20; ++i) > { >if

Re: [algogeeks] Re: question on fork()

2011-08-22 Thread gmagog...@gmail.com
I am getting 6 red and 8 green as expected using the original code Yanan Cao On Mon, Aug 22, 2011 at 2:38 PM, Yasir wrote: > Surprisingly, if I comment the last if condition ( which is AFTER red() > call ), it is printing red only 6 times as expected.. > http://ideone.com/XMHzC > > main() > {