Updated mutextest - it is not yet there, we need semaphores

This commit is contained in:
Bahadir Balban
2009-05-31 14:18:19 +03:00
parent ce79aa2b73
commit d0652fcb21
3 changed files with 14 additions and 12 deletions

View File

@@ -52,9 +52,9 @@ void main(void)
ipc_full_test(); ipc_full_test();
ipc_extended_test(); ipc_extended_test();
} }
if (parent_of_all == getpid()) { // if (parent_of_all == getpid()) {
user_mutex_test(); // user_mutex_test();
} // }
exectest(); exectest();
while (1) while (1)

View File

@@ -81,7 +81,8 @@ void ipc_extended_test(void)
__FUNCTION__, (int)base); __FUNCTION__, (int)base);
goto out_err; goto out_err;
} else } 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 * Both tasks read/write both pages

View File

@@ -67,12 +67,12 @@ int user_mutex_test(void)
l4_mutex_init(&shared_page->mutex); l4_mutex_init(&shared_page->mutex);
/* Initialize buffer with unique child value */ /* Initialize buffer with unique child value */
printf("Child writing:\n"); printf("Initializing shared page with child values.\n");
for (int i = 0; i < buf_size; i++) { 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'; shared_page->page_rest[i] = 'c';
printf("%c", shared_page->page_rest[i]);
}
printf("\n\n");
/* Fork the current task */ /* Fork the current task */
if ((child = fork()) < 0) { if ((child = fork()) < 0) {
@@ -124,23 +124,24 @@ int user_mutex_test(void)
l4_mutex_lock(&shared_page->mutex); l4_mutex_lock(&shared_page->mutex);
printf("Parent locked page.\n"); printf("Parent locked page.\n");
printf("Parent reading:\n"); // printf("Parent reading:\n");
/* Test and consume the page */ /* Test and consume the page */
for (int i = 0; i < buf_size; i++) { 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 */ /* Test that child has produced */
if (shared_page->page_rest[i] != 'c') { if (shared_page->page_rest[i] != 'c') {
printf("Child not produced. " printf("Child not produced. "
"page_rest[%d] = %c, " "page_rest[%d] = %c, "
"expected = 'c'\n", "expected = 'c'\n",
i, shared_page->page_rest[i]); i, shared_page->page_rest[i]);
BUG();
goto out_err; goto out_err;
} }
/* Consume the page */ /* Consume the page */
shared_page->page_rest[i] = 'P'; shared_page->page_rest[i] = 'P';
} }
printf("\n\n"); // printf("\n\n");
printf("Parent consumed.\n"); printf("Parent consumed.\n");
l4_mutex_unlock(&shared_page->mutex); l4_mutex_unlock(&shared_page->mutex);
printf("Parent unlocked page.\n"); printf("Parent unlocked page.\n");