Skip to content

abhivijay96/fork

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fork call tree builder

Instructions to run:


compile fork.c
gcc fork.c -o fork.out
Run the compiled code
./fork.out

How it works:


C code


The c program asks the user the number of times it should fork. After every fork the parent waits for the child to complete using wait system call and whenever a leaf fork child completes execution all the nodes in that path from the parent resume execution from bottom up and write to the output.txt file in the format PARENT parent_pid CHILD child_pid this does not cause race condition because of the wait call.

Python code


Then the python file tree_generator.py is invoked which parses data in output.txt and creates a dictionary where keys are pids of parents and value is list of pids of child processes, this list is then used to create a tree and the tree is dumped as a json object to tree.json file which contains node values as the pid of every process.

Results:


The sample tree.json contains results for 7 consecutive fork calls.

About

Get tree structures of repeated fork calls

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published