I'm currently revising for an concurrent programming exam and would like some thoughts on the following questions.
1. Given the following tree, write a fragment of code that produce processes (using fork()) given the form of the tree.
* parent / \ / \ / \ child 1 * * child 2 / \ / \ / \ child 1 * * child 2 . . .
2. What is the effect of the following fragments of unix/c code? Illustrate with a binary tree
while(fork() == 0)
Here I'm guessing only the child will continue forking, but what would the tree look like?
while(fork() > 0)
In this one the think the parent would continue forking so how would a tree be form?
So far I have a general understanding that processes calling (parent) get the child pid returned from the fork() call and new process created (child) has 0 returned from the fork() call.
However, I can't seem to get my head around how to take these code fragments and make them into trees and vice-versa.
Any ideas? Thanks in advance.

New Topic/Question
Reply



MultiQuote




|