Home > Back-end >  Fork () to create two child process, the parent process display character, A child process respectiv
Fork () to create two child process, the parent process display character, A child process respectiv

Time:03-22

#include
#include
#include
#include

Int main ()
{
Int pid1=fork ();
If (pid1 & lt; 0)
{
Printf (" failed to create the child \ n ");
}
Else if (pid1==0)
{
Printf (" \ n B ");
}
Else if (pid1 & gt; 0)
{
//create a child process
Int pid2=fork ();
If (pid2 & lt; 0)
{
Printf (" failed to create the child \ n ");
}
Else if (pid2==0)
{
Printf (" C \ n ");
}
The else
{
Printf (" A \ n ");
}
}
return 0;
}

CodePudding user response:

Because A and C are not output together, they two output in different processes, are independent of each other,
A, B, C to output that is random ~

CodePudding user response:

To solve the
Problem: virtual machine is a single core
Then increase the quantity of nuclear to normal

CodePudding user response:

How to increase the number of nuclear

CodePudding user response:

refer to the second floor of the wind continued to Z response:
solved
Problem: virtual machine is a single core
Then increase the quantity of nuclear to normal
how to increase the number of nuclear
  • Related