'How many process and thread does this code create?
int main( ) {
pid t pid1, pid2;
pid1 = fork ( );
pid2 = fork ( );
if (pid1 == 0) { /* child process */
pthread_create (. . .);
}
if (pid2 > 0) { /* parent process */
pthread_create (. . .);
}
}
I think it creates 8 processes.
if (pid2 > 0) { /* parent process */
pthread_create (. . .);
}
I am not sure about the number of threads though. Does each thread have child with pid 0 and pid greater than 0, so 16 threads?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
