From 710010861c0b795e768f1ef71632b9baf24034b6 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 17 Apr 2014 09:45:42 +0200 Subject: Update due to workspace allocation changes --- testsuite/thread01/test_main.c | 77 +++++++++++++++++++++--------------------- 1 file 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 +#include #include #include @@ -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); } -- cgit v1.2.3