Skip to content
Snippets Groups Projects
Commit 2b85ac6d authored by FKHals's avatar FKHals
Browse files

Enhance documentation to fork separation and join

parent 3471a62d
Branches
No related tags found
No related merge requests found
......@@ -391,6 +391,18 @@ int pbm_task_end(PBM* pbm) {
return 0;
}
/**
* Why is the code concerning the forking separated into the two functions
* pbm_fork_parent_new_task() and pbm_fork() instead of simply putting it at the end of _do_fork?
*
* The separation is necessary since in the _do_fork a context switch from the parent to the
* child process takes place which is problematic since we want to end (and restart) perf-measuring
* the parent as well as the child process and the measurements (in pbm_task_end()) can only happen
* from the process itself. But in the beginning of _do_fork the child process does not exist yet.
* Therefore we have to split the code into the two functions to be able to measure the parent
* before the context switch as well as initialize the child-measuring after switching to the child.
*/
/* Stop previous task and start new task for the parent process and also reset the perf counter
* Returns a pointer to the fork-task-node which the forked process can use as a time information.
*
......@@ -572,6 +584,7 @@ int pbm_exit(pid_t pid, pid_t parent_pid) {
int pbm_join(PBM* child_pbm) {
pbm_NODE* fork_node;
pbm_NODE* join_node;
pid_t join_label;
if(!child_pbm)
return 0;
......@@ -579,7 +592,11 @@ int pbm_join(PBM* child_pbm) {
printk(KERN_WARNING "Joining thread %u with fork_node: %lli\n", child_pbm->last->thread_id, task_2_index(child_pbm->fork_date));
fork_node = child_pbm->fork_date;
join_node = _pbm_create_node(JOIN, child_pbm->last->thread_id/*fork_node->thread_id*/); // FIXME????
// the child process is used to label the join operation to know which process the join belongs
// to since using the parent as the label would be ambiguous since more than one child could
// have been spawned by the same parent
join_label = child_pbm->last->thread_id;
join_node = _pbm_create_node(JOIN, child_pbm->last->thread_id);
if(!join_node) {
printk(KERN_WARNING "ERROR: Could not create node!\n");
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment