summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-04-17 09:45:42 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-05-14 09:11:37 +0200
commit710010861c0b795e768f1ef71632b9baf24034b6 (patch)
tree1d53cdc767a8c47dc9c95b35983aa5457f0fc09f
parentUpdate due to shell API changes (diff)
downloadrtems-libbsd-710010861c0b795e768f1ef71632b9baf24034b6.tar.bz2
Update due to workspace allocation changes
-rw-r--r--testsuite/thread01/test_main.c77
1 files changed, 38 insertions, 39 deletions
diff --git a/testsuite/thread01/test_main.c b/testsuite/thread01/test_main.c
index 2891e3f5..2fd13ea2 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);
}