diff --git a/kernel/fork.c b/kernel/fork.c index b7e9e57b71eaef65bd56b409b32b582e9b16ed4a..c4ccda40ce7d9049a39f1c0122be3a6515e8f1c8 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -98,6 +98,8 @@ #include <trace/events/sched.h> +#include "sched/perf_error_detection.h" + #define CREATE_TRACE_POINTS #include <trace/events/task.h> @@ -2069,6 +2071,17 @@ long _do_fork(unsigned long clone_flags, } 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 { nr = PTR_ERR(p); } diff --git a/pb_utils/pb_submitter/test_prog.c b/pb_utils/pb_submitter/test_prog.c index 98e6bece6dc9aa24c774aa8af1145379c5f40ec0..57467d38813a7d77cdf53702d00b893fcbea466c 100644 --- a/pb_utils/pb_submitter/test_prog.c +++ b/pb_utils/pb_submitter/test_prog.c @@ -1,25 +1,50 @@ #include <stdio.h> #include <unistd.h> +#define NUM_CHILDS 1 + int main(void) { - int i; + int id; 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 - sleep(1); + for (id = 0; id < NUM_CHILDS; id++) { + 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 - for (i = 0; i < 100; i++) { - // this for loop results in 4 cpu instructions per iteration - // nop, add, compare, jmp - for (j = 0; j < 100000; j++){ - __asm__ volatile("nop"); + // this for loop results in 4 cpu instructions per iteration + // nop, add, compare, jmp + 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 - printf("run #%d completed\n", i); - usleep(1); +- printf("run completed\n"); +- usleep(1); } printf("main end\n");