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

[SQUASH ME] Another intermediate commit

parent 56b8c56f
Branches
No related tags found
No related merge requests found
......@@ -772,6 +772,29 @@ void __noreturn do_exit(long code)
rq = this_rq();
/**
* BEWARE:
* We want to update the plan runtime model not too early to ensure that the exiting process
* has already signaled its exit to its parents otherwise the scheduler could switch the
* process to early to the parent which itself is waiting for the child to exit which leads to
* a deadlock!
* But we also do not want to update it too late since then the model would not be up to date
* when the next task should be picked and therefore the child would remain the current process
* of the model which also would lead to a deadlock since the child will never be replaced by
* the runnable parent.
* We want to update the model exactly after the childs exit-signal is sent to the parent.
*/
// prevent syscalls from outside of the measured program (e.g. admin tasks) to be recognized
if (PB_EXEC_MODE == rq->pb.mode) {
printk(KERN_WARNING "TASK DEAD: %u\n", tsk->pid);
// inform the pb-scheduler knows which syscall triggered the scheduling
rq->pb.triggering_syscall.type = sched_trig_EXIT;
rq->pb.triggering_syscall.origin = current;
// inform the plan runtime state
plan_rt_state_incr_num_exited_procs();
}
// call the readout before the process is terminated
if (is_relevant_process(tsk)) {
pbm_exit(tsk->pid, tsk->real_parent->pid);
......@@ -910,29 +933,6 @@ void __noreturn do_exit(long code)
TASKS_RCU(preempt_enable());
exit_notify(tsk, group_dead);
/**
* BEWARE:
* We want to update the plan runtime model not too early to ensure that the exiting process
* has already signaled its exit to its parents otherwise the scheduler could switch the
* process to early to the parent which itself is waiting for the child to exit which leads to
* a deadlock!
* But we also do not want to update it too late since then the model would not be up to date
* when the next task should be picked and therefore the child would remain the current process
* of the model which also would lead to a deadlock since the child will never be replaced by
* the runnable parent.
* We want to update the model exactly after the childs exit-signal is sent to the parent.
*/
// prevent syscalls from outside of the measured program (e.g. admin tasks) to be recognized
if (PB_EXEC_MODE == rq->pb.mode) {
printk(KERN_WARNING "TASK DEAD: %u\n", tsk->pid);
// inform the pb-scheduler knows which syscall triggered the scheduling
rq->pb.triggering_syscall.type = sched_trig_EXIT;
rq->pb.triggering_syscall.origin = current;
// inform the plan runtime state
plan_rt_state_incr_num_exited_procs();
}
proc_exit_connector(tsk);
mpol_put_task_policy(tsk);
#ifdef CONFIG_FUTEX
......
......@@ -294,6 +294,7 @@ static void dequeue_task_pb(struct rq *rq, struct task_struct *p, int flags)
printk("Dequeue task: %u\n", p->pid);
if (pb->waiting_on_io) {
printk("Waiting for IO\n", p->pid);
return;
}
pb->waiting_on_io = 1;
......@@ -307,6 +308,7 @@ static void dequeue_task_pb(struct rq *rq, struct task_struct *p, int flags)
printk("WARNING: PERF EVENT IS NULL");
}
printk(KERN_WARNING Bold Red "EXIT? %i" End "\n", pb->triggering_syscall.type);
if (pb->triggering_syscall.type == sched_trig_EXIT) {
printk(KERN_WARNING Bold Red "EXIT TRIGGERED THIS!!!" End "\n");
// remove the exited process from the stack and run the next available
......
#!/bin/bash
IMG=build/qemu-image.img
DIR=build/mount-point.dir
KEYRING=build/debian-keyring.gpg
DEBIAN_VERSION=jessie
DEBOOTSTRAP_FOLDER=$PWD/build/debootstrap
DEBOOTSTRAP_SOURCE=https://deb.debian.org/debian/pool/main/d/debootstrap
MIRROR=https://archive.debian.org/debian-archive/debian
# get dbootstrap
if [ ! -d $DEBOOTSTRAP_FOLDER ]
then
if [ ! -d $DEBOOTSTRAP_FOLDER ]; then
mkdir -p $DEBOOTSTRAP_FOLDER
# get versions sorted ascendingly by last modification (?C=M;O=A supported by apache servers
# which makes something like sort -V unnecessary which also can not take the modification date
......
......@@ -10,23 +10,36 @@ int main(void)
// Creating first child
pid_t n1 = fork();
if (n1 > 0)
{
fprintf(stderr, "Parent %d of %d\n", getpid(), n1);
// Creating second child. First child
// also executes this line and creates
// grandchild.
pid_t n2 = fork();
// barrier: make all fathers wait for all its child processes (since all processes use that line)
while ((wpid = wait(&status)) > 0) {fprintf(stderr, "%d waiting...\n", getpid());};
while ((wpid = wait(&status)) > 0) {};
if (n1 > 0 && n2 > 0)
{
fprintf(stderr, "Parent %d of %d %d\n", getpid(), n1, n2);
// check if program runs && syscall to switch tasks
fprintf(stderr, "run completed\n");
// TODO WHY IS THIS NECESSARY?!
usleep(1);
}
else
else if (n1 == 0 && n2 > 0)
{
// set a different process name (comm) for the child to differentiate it from the parent
prctl(PR_SET_NAME, "test_child");
fprintf(stderr, "Child %d of %d\n", getpid(), n1);
prctl(PR_SET_NAME, "test_child_1");
fprintf(stderr, "First child %d of %d %d\n", getpid(), n1, n2);
}
else if (n1 > 0 && n2 == 0)
{
prctl(PR_SET_NAME, "test_child_2");
fprintf(stderr, "Second child %d of %d %d\n", getpid(), n1, n2);
}
else {
prctl(PR_SET_NAME, "test_child_3");
fprintf(stderr, "Third child %d of %d %d\n", getpid(), n1, n2);
}
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment