-
Notifications
You must be signed in to change notification settings - Fork 25
Forking
Lucas Morris edited this page Jun 21, 2014
·
2 revisions
So for forking, we're going to handle it as so:
- 2 semaphores
-
- 1 for if we're locking the output file
-
- 1 for if we're done reading from our input and the child should quit when its done.
- 1 queue for new targets
The parent will setup, fork, and then will read lines into the queue and block when the queue is full, adding new targets in as there is space. The children will read things from the queue (there will be a timeout on the recv function so that the children occasionally check to see if the queue is empty), the smb.c functions will be called (runtarget), and then the child main will then lock the semaphore, write to the output file, print a message to stdout, then unlock the semaphore. Children will block on the semaphore until they are able to lock. The parent will block until all of the children have exited, and will then exit.