Skip to content
Snippets Groups Projects
Commit 5d890d80 authored by FKHals's avatar FKHals
Browse files

[DO NOT MERGE] Intermediate commit

parent 20c76ea2
No related branches found
No related tags found
No related merge requests found
...@@ -98,6 +98,8 @@ ...@@ -98,6 +98,8 @@
#include <trace/events/sched.h> #include <trace/events/sched.h>
#include "sched/perf_error_detection.h"
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include <trace/events/task.h> #include <trace/events/task.h>
...@@ -2069,6 +2071,17 @@ long _do_fork(unsigned long clone_flags, ...@@ -2069,6 +2071,17 @@ long _do_fork(unsigned long clone_flags,
} }
put_pid(pid); put_pid(pid);
/*
struct rq* rq = this_rq();
struct pb_rq *pb = &(rq->pb);
if (pb && pb->is_initialized) {
u64 perf_counter;
u64 read_error = get_perf_counter(pb->pevent, &perf_counter);
if (read_error) {
printk(KERN_WARNING "FORK: FETCHING PERFORMANCE COUNTER IN PB SCHEDULER FAILED WITH %llu\n", read_error);
}
printk("FORK: PERFORMANCE COUNTER: %llu", perf_counter);
}*/
} else { } else {
nr = PTR_ERR(p); nr = PTR_ERR(p);
} }
......
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#define NUM_CHILDS 1
int main(void) int main(void)
{ {
int i; int id;
int j; int j;
pid_t child_pid, wpid;
int status = 0;
// parent code (before child processes start)
{
// Make sure program is not finished before pb scheduler takes control
sleep(1);
printf("=========================================================\n");
printf("I am the parent=%d and i am going to do some forking...\n", getpid());
}
// Make sure program is not finished before pb scheduler takes control for (id = 0; id < NUM_CHILDS; id++) {
sleep(1); if ((child_pid = fork()) == 0) {
// child code
{
printf("I am the child, return from fork=%d with parent=%d\n", getpid(), getppid());
// this outer for loop is around 8 instructions per iteration // this for loop results in 4 cpu instructions per iteration
for (i = 0; i < 100; i++) { // nop, add, compare, jmp
// this for loop results in 4 cpu instructions per iteration for (j = 0; j < 100000; j++){
// nop, add, compare, jmp __asm__ volatile("nop");
for (j = 0; j < 100000; j++){ }
__asm__ volatile("nop"); printf("Child %d exiting\n", getpid());
}
} }
}
// barrier: let the father wait for all the child processes
while ((wpid = wait(&status)) > 0) {};
// parent code (after all child processes end)
{
printf("Parent exiting!\n");
// check if program runs && syscall to switch tasks // check if program runs && syscall to switch tasks
printf("run #%d completed\n", i); - printf("run completed\n");
usleep(1); - usleep(1);
} }
printf("main end\n"); printf("main end\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment