diff options
author | Kenneth Chan <kchan049@ucr.edu> | 2016-11-07 14:17:43 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-07 14:17:43 -0800 |
commit | dcf4ebe433c2c220c5c4b8aa5edf38f6d9a3b8f6 (patch) | |
tree | 8b3987006c8e355ad2a448ff273fe553ce0134e0 | |
parent | 041e5a8debb7510458916a733bb2d9989a48010b (diff) | |
download | towelroot-dcf4ebe433c2c220c5c4b8aa5edf38f6d9a3b8f6.tar.gz towelroot-dcf4ebe433c2c220c5c4b8aa5edf38f6d9a3b8f6.tar.bz2 towelroot-dcf4ebe433c2c220c5c4b8aa5edf38f6d9a3b8f6.zip |
Delete towelroot.c
-rw-r--r-- | towelroot.c | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/towelroot.c b/towelroot.c deleted file mode 100644 index 51c2962..0000000 --- a/towelroot.c +++ /dev/null @@ -1,56 +0,0 @@ -#include <stdio.h> -#include <unistd.h> -#include <pthread.h> -#include <linux/futex.h> -#include "userlock.h" - -int A = 0, B = 0; - -volatile int invoke_futex_wait_requeue_pi = 0; -volatile pid_t thread_tid = -1; - -void *thread(void *arg) -{ - thread_tid = gettid(); - printf("[2]\n"); - userlock_wait(&invoke_futex_wait_requeue_pi); - futex_wait_requeue_pi(&A, &B); - printf("Someone woke me up\n"); - while (1) { - sleep(1); - } -} - -int main(int argc, char *argv[]) -{ - pthread_t t; - int context_switch_count = 0; - - printf("[1]\n"); - - futex_lock_pi(&B); - - userlock_lock(&invoke_futex_wait_requeue_pi); - pthread_create(&t, NULL, thread, NULL); - /* Wait for the thread to be in a system call */ - while (thread_tid < 0) { - usleep(10); - } - context_switch_count = get_voluntary_ctxt_switches(thread_tid); - userlock_release(&invoke_futex_wait_requeue_pi); - wait_for_thread_to_wait_in_kernel(thread_tid, context_switch_count); - - printf("[3]\n"); - futex_requeue_pi(&A, &B, A); - - printf("[4]\n"); - B = 0; - - printf("[5]\n"); - futex_requeue_pi(&B, &B, B); - - while (1) { - sleep(1); - } - return 0; -} |