Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Fork help

Name: Anonymous 2011-11-03 1:58

Programming help..
  A
/ | \
B C D
 / \ \
 E F  G
For our assignment we are supposed to (in writing) say how we can perform the creation of said processes using 6, 5, 4, and 3 fork calls. I can understand 6 calls easy enough, but I am a little confused on how to accomplish it with less.

My basic thought is to do the initial fork, then if the pid is 0 do some condition to fork again.. but I am a little confused. Any help would be appreciated. I don't need the code, and I don't need all of the solved, just a little push in the right direction.

Name: Anonymous 2011-11-03 1:58

Formatting is off, sorry.

A is parent to B C D. B has no children, C has children E and F, D has child G.

Name: Anonymous 2011-11-03 2:01

Fixed for you:

  A
/ | \
B C D
 / \ \
 E F  G

use [m]text[/m] for monospaced text

Name: Anonymous 2011-11-03 2:02

Thanks!

Name: Anonymous 2011-11-03 5:05

Here is a dot version of your directed acyclic graph
File: fork.dot
digraph Hierarchy {
  rankdir=TB;
  "A"->"B";
  "A"->"C";
  "A"->"D";
  "C"->"E";
  "C"->"F";
  "D"->"G";
}


Invoke with $ dot -Txlib fork.dot.

Name: Anonymous 2011-11-03 5:08

By the way >>5 indicates that most effective representation from a spatial perspective is as you don't need extra space for the G node.


  A
 /|\
B C D
 /| |
E F G

Name: Anonymous 2011-11-03 5:12

Well if it's just in writing, describe a fork that can fork more than one child at once.

Name: Anonymous 2011-11-03 5:17


NAME
     spork -- generate a random process

SYNOPSIS
     #include <cutlery.h>

     void
     spork(void);


DESCRIPTION
     spork() generates a new, random process by blending
     characteristics from the calling process and the process
     which most recently invoked spoon() in the current
     process group. These characteristics may include any or
     all of the following:

     * Current working directory
     * Open file descriptors, directory streams, and
       memory-mapped files (open(2), opendir(3), mmap(2))
     * Environment variables
     * Memory and record locks (mlock(2), flock(2))
     * Resource limits

     Pending asynchronous I/O operations, semaphores, and
     timers are not inherited by the spork()ed process.
     Threading behaves similarly to fork(), i.e. handlers
     defined with pthread_atfork(3) in both the fork() and
     spoon() processes are invoked when calling spork().


RETURN VALUES
     spork() returns 0 on success, and nonzero on error.


ERRORS
     spork() will fail and subsequent spork() will fail if:

     [ENOMEM]     Not enough memoory is available to create
                  the task structure for the new process.


SEE ALSO
     execve(2), fork(2), spoon(2)


HISTORY
     A spork() function call appeared in Anonix Prerelease -7.

Name: Anonymous 2011-11-03 5:19

To help you the depth of the tree is 3.

Name: Anonymous 2011-11-03 5:30

>>8
Which language has by as a keyword?

Name: Anonymous 2011-11-03 5:43

>>10
Visual Basic

Name: Anonymous 2011-11-03 5:46

Name: Anonymous 2011-11-03 5:55

>>11,12
Compelling.

Name: Anonymous 2011-11-03 13:34

>>10
English.

Name: Anonymous 2011-11-03 15:14

>>14
English has words but not keywords.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List