6 red 10 greens
On Wed, Aug 24, 2011 at 9:25 AM, Ankuj Gupta ankuj2...@gmail.com wrote:
how can be there 20 greens ?
On Aug 24, 12:12 am, DK divyekap...@gmail.com wrote:
The standard library is neither multithread safe nor multiprocess safe.
If you want the correct answer, use shared
@Ankuj: Sorry. I read the getch() as a call to green().
Please ignore the 20 green(). It should be 10 green() instead.
--
DK
http://twitter.com/divyekapoor
http://www.divye.in
http://gplus.to/divyekapoor
--
You received this message because you are subscribed to the Google Groups
Algorithm
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 gmagog...@gmail.comwrote:
Infinite times
Yanan Cao
On Mon, Aug 22, 2011 at 2:43 PM, Don dondod...@gmail.com wrote:
// DO NOT RUN THIS! By inspection,
The standard library is neither multithread safe nor multiprocess safe.
If you want the correct answer, use shared memory and maintain a shared
counter. Alternatively, as a quick hack, insert a fflush(stdout) after the
printf statements.
Answer:
red() - 6
green() - 20
--
DK
how can be there 20 greens ?
On Aug 24, 12:12 am, DK divyekap...@gmail.com wrote:
The standard library is neither multithread safe nor multiprocess safe.
If you want the correct answer, use shared memory and maintain a shared
counter. Alternatively, as a quick hack, insert a fflush(stdout)
I am getting 6 calls to red and 8 calls to green when i built parent
child tree but when i ran this code
http://ideone.com/UBaBB
I got 10 calls to red and 10 calls to green.
Can some explain this ?
On Aug 22, 9:31 pm, ghsjgl k ghsk...@gmail.com wrote:
i saw this question in one of DREAM
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()
{
fork();
int color=fork();
if(color==0)
fork();
red();
//if(color==0)
//
// 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 (fork() 0) ++j;
else i = j = 0;
printf(Hello world\n);
}
return 0;
}
--
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 yasir@gmail.com wrote:
Surprisingly, if I comment the last if condition ( which is AFTER red()
call ), it is printing red only 6 times as expected..
Infinite times
Yanan Cao
On Mon, Aug 22, 2011 at 2:43 PM, Don dondod...@gmail.com 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)
10 matches
Mail list logo