Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kernel Program Behaviour Models
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
felixkhals
Kernel Program Behaviour Models
Commits
2b85ac6d
Commit
2b85ac6d
authored
Mar 17, 2023
by
FKHals
Browse files
Options
Downloads
Patches
Plain Diff
Enhance documentation to fork separation and join
parent
3471a62d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
kernel/behave.c
+18
-1
18 additions, 1 deletion
kernel/behave.c
with
18 additions
and
1 deletion
kernel/behave.c
+
18
−
1
View file @
2b85ac6d
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment