mirror of
https://github.com/drasko/codezero.git
synced 2026-04-06 20:19:04 +02:00
Updated mutextest - it is not yet there, we need semaphores
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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");
|
||||||
|
|||||||
Reference in New Issue
Block a user