From d0652fcb2175658a2948e303c1d8a135528a15ed Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Sun, 31 May 2009 14:18:19 +0300 Subject: [PATCH] Updated mutextest - it is not yet there, we need semaphores --- tasks/test0/main.c | 6 +++--- tasks/test0/src/ipctest.c | 3 ++- tasks/test0/src/mutextest.c | 17 +++++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tasks/test0/main.c b/tasks/test0/main.c index c0f039a..3b4b991 100644 --- a/tasks/test0/main.c +++ b/tasks/test0/main.c @@ -52,9 +52,9 @@ void main(void) ipc_full_test(); ipc_extended_test(); } - if (parent_of_all == getpid()) { - user_mutex_test(); - } +// if (parent_of_all == getpid()) { +// user_mutex_test(); +// } exectest(); while (1) diff --git a/tasks/test0/src/ipctest.c b/tasks/test0/src/ipctest.c index 1982709..150b016 100644 --- a/tasks/test0/src/ipctest.c +++ b/tasks/test0/src/ipctest.c @@ -81,7 +81,8 @@ void ipc_extended_test(void) __FUNCTION__, (int)base); goto out_err; } else - test_printf("mmap: Anonymous private buffer at %p\n", base); + test_printf("%s: mmap: Anonymous private buffer at %p\n", + __FUNCTION__, base); /* * Both tasks read/write both pages diff --git a/tasks/test0/src/mutextest.c b/tasks/test0/src/mutextest.c index 7b6546e..627c53e 100644 --- a/tasks/test0/src/mutextest.c +++ b/tasks/test0/src/mutextest.c @@ -67,12 +67,12 @@ int user_mutex_test(void) l4_mutex_init(&shared_page->mutex); /* Initialize buffer with unique child value */ - printf("Child writing:\n"); - for (int i = 0; i < buf_size; i++) { + printf("Initializing shared page with child values.\n"); + BUG(); + shared_page->child_has_run = 0; + shared_page->parent_has_run = 0; + for (int i = 0; i < buf_size; i++) shared_page->page_rest[i] = 'c'; - printf("%c", shared_page->page_rest[i]); - } - printf("\n\n"); /* Fork the current task */ if ((child = fork()) < 0) { @@ -124,23 +124,24 @@ int user_mutex_test(void) l4_mutex_lock(&shared_page->mutex); printf("Parent locked page.\n"); - printf("Parent reading:\n"); + // printf("Parent reading:\n"); /* Test and consume the page */ for (int i = 0; i < buf_size; i++) { - printf("%c", shared_page->page_rest[i]); + // printf("%c", shared_page->page_rest[i]); /* Test that child has produced */ if (shared_page->page_rest[i] != 'c') { printf("Child not produced. " "page_rest[%d] = %c, " "expected = 'c'\n", i, shared_page->page_rest[i]); + BUG(); goto out_err; } /* Consume the page */ shared_page->page_rest[i] = 'P'; } - printf("\n\n"); + // printf("\n\n"); printf("Parent consumed.\n"); l4_mutex_unlock(&shared_page->mutex); printf("Parent unlocked page.\n");