Quantcast
Channel: Active questions tagged operating-system+scheduling - Stack Overflow
Viewing all articles
Browse latest Browse all 209

Visualizing processes created by fork() using directed graph

$
0
0
01  int main(){02      int a=10;03      fork();04      fork();05      printf("%d ", a);07      return 0;08  }

I am looking for an elegant way to visualize the spawned processes with the help of a graph. I came up with an idea, but this does not take into account the order of execution of each of the processes. My idea goes like this:

Process states are represented as ProcessName(InstPointer). InstPointer points to the line number to be executed for a process. A parent process always points to its child process.

Program starts, P is the parent process:

P(1)

Line 3 executes, child process A is spawned:

P(4) | | vA(4)

Line 4 executes, child processes B, C are spawned:

P(5) | \ |  \ v   \A(5)  \ |    | |    | v    vB(5) C(5)

It somewhat helps me visualize the spawned processes, but I am still unsure whether this has any serious pitfalls. If anyone has any better ideas, please feel free to share!


Viewing all articles
Browse latest Browse all 209

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>