this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Somewhat working psynch_mutex

+17 -3
+17 -3
src/lkm/psynch/psynch_mutex.c
··· 19 19 20 20 #include "psynch_mutex.h" 21 21 #include "../darling_task.h" 22 + #include "../debug.h" 22 23 #include <linux/sched.h> 23 24 #include <linux/wait.h> 24 25 #include <linux/list.h> ··· 56 57 if (copy_from_user(&args, in_args, sizeof(args))) 57 58 return -EFAULT; 58 59 60 + debug_msg("psynch_mutexwait_trap(%d): mutex=0x%llx, mgen=0x%x\n", 61 + current->pid, args.mutex, args.mgen); 59 62 spin_lock(&task->mutex_wq_lock); 60 63 61 64 mutex = mutex_get(task, args.mutex); 62 65 63 - if (mutex->mgen == 0) 66 + if (mutex->mgen != 0) 64 67 { 65 68 spin_unlock(&task->mutex_wq_lock); 66 69 67 - retval = 0; 70 + // Put the mutex twice, because the waker did not put the mutex 71 + // in order to keep the information around 72 + mutex_put(task, mutex); 73 + mutex_put(task, mutex); 74 + 75 + retval = mutex->mgen; 68 76 goto out; 69 77 } 70 78 ··· 79 87 list_del(&waiter.entry); 80 88 81 89 if (waiter.wakeup) 90 + { 82 91 retval = mutex->mgen; 92 + mutex->mgen = 0; 93 + } 94 + debug_msg("(%d)--> retval: 0x%x\n", current->pid, retval); 83 95 84 96 mutex_put(task, mutex); 85 97 spin_unlock(&task->mutex_wq_lock); ··· 97 109 if (copy_from_user(&args, in_args, sizeof(args))) 98 110 return -EFAULT; 99 111 112 + debug_msg("psynch_mutexdrop_trap(%d): mutex=0x%llx, mgen=0x%x\n", 113 + current->pid, args.mutex, args.mgen); 100 114 spin_lock(&task->mutex_wq_lock); 101 115 102 116 mutex = mutex_get(task, args.mutex); ··· 112 126 waiter->wakeup = 1; 113 127 114 128 wake_up_interruptible(&mutex->wq); 129 + mutex_put(task, mutex); 115 130 } 116 131 117 - mutex_put(task, mutex); 118 132 spin_unlock(&task->mutex_wq_lock); 119 133 120 134 return 0;