[rtems-libbsd commit] Update due to workspace allocation changes
Sebastian Huber
sebh at rtems.org
Wed May 14 07:11:42 UTC 2014
Module: rtems-libbsd
Branch: master
Commit: 710010861c0b795e768f1ef71632b9baf24034b6
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=710010861c0b795e768f1ef71632b9baf24034b6
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Apr 17 09:45:42 2014 +0200
Update due to workspace allocation changes
---
testsuite/thread01/test_main.c | 77 +++++++++++++++++++--------------------
1 files changed, 38 insertions(+), 39 deletions(-)
diff --git a/testsuite/thread01/test_main.c b/testsuite/thread01/test_main.c
index 2891e3f..2fd13ea 100644
--- a/testsuite/thread01/test_main.c
+++ b/testsuite/thread01/test_main.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -30,6 +30,7 @@
*/
#include <machine/rtems-bsd-kernel-space.h>
+#include <machine/rtems-bsd-thread.h>
#include <stdlib.h>
#include <stdio.h>
@@ -208,58 +209,56 @@ static void
test_kthread_add(void)
{
rtems_resource_snapshot snapshot;
- uintptr_t take_away;
void *greedy;
+ uintptr_t take_away = 2 * BSD_MINIMUM_TASK_STACK_SIZE;
puts("test kthread_add()");
- greedy = rtems_workspace_greedy_allocate_all_except_largest(&take_away);
+ greedy = rtems_workspace_greedy_allocate(&take_away, 1);
rtems_resource_snapshot_take(&snapshot);
assert(rtems_configuration_get_unified_work_area());
while (take_away > 0) {
- struct thread *td = NULL;
void *away;
- int eno;
-
- /*
- * FIXME: This direct workspace access is a hack to get
- * reasonable test run times with RTEMS_DEBUG enabled.
- */
- _Thread_Disable_dispatch();
- away = _Workspace_Allocate(take_away);
- _Thread_Enable_dispatch();
-
- eno = kthread_add(
- test_kthread_add_thread,
- TEST_KTHREAD_ADD,
- NULL,
- &td,
- 0,
- 0,
- "%s",
- &test_kthread_name[0]
- );
-
- _Thread_Disable_dispatch();
- _Workspace_Free(away);
- _Thread_Enable_dispatch();
-
- if (eno == 0) {
- wait_for_worker_thread();
- assert(td != NULL);
-
- take_away = 0;
- } else {
- assert(eno == ENOMEM);
- assert(rtems_resource_snapshot_check(&snapshot));
-
- --take_away;
+ bool ok;
+
+ ok = rtems_workspace_allocate(take_away, &away);
+ if (ok) {
+ struct thread *td = NULL;
+ int eno;
+
+ eno = kthread_add(
+ test_kthread_add_thread,
+ TEST_KTHREAD_ADD,
+ NULL,
+ &td,
+ 0,
+ 0,
+ "%s",
+ &test_kthread_name[0]
+ );
+
+ ok = rtems_workspace_free(away);
+ assert(ok);
+
+ if (eno == 0) {
+ wait_for_worker_thread();
+ assert(td != NULL);
+
+ break;
+ } else {
+ assert(eno == ENOMEM);
+ assert(rtems_resource_snapshot_check(&snapshot));
+ }
}
+
+ --take_away;
}
+ assert(take_away > 0);
+
rtems_workspace_greedy_free(greedy);
}
More information about the vc
mailing list