Update due to workspace allocation changes

This commit is contained in:
Sebastian Huber 2014-04-17 09:45:42 +02:00
parent 9219a29a90
commit 710010861c

View File

@ -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 * embedded brains GmbH
* Dornierstr. 4 * Dornierstr. 4
@ -30,6 +30,7 @@
*/ */
#include <machine/rtems-bsd-kernel-space.h> #include <machine/rtems-bsd-kernel-space.h>
#include <machine/rtems-bsd-thread.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -208,58 +209,56 @@ static void
test_kthread_add(void) test_kthread_add(void)
{ {
rtems_resource_snapshot snapshot; rtems_resource_snapshot snapshot;
uintptr_t take_away;
void *greedy; void *greedy;
uintptr_t take_away = 2 * BSD_MINIMUM_TASK_STACK_SIZE;
puts("test kthread_add()"); 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); rtems_resource_snapshot_take(&snapshot);
assert(rtems_configuration_get_unified_work_area()); assert(rtems_configuration_get_unified_work_area());
while (take_away > 0) { while (take_away > 0) {
struct thread *td = NULL;
void *away; void *away;
int eno; bool ok;
/* ok = rtems_workspace_allocate(take_away, &away);
* FIXME: This direct workspace access is a hack to get if (ok) {
* reasonable test run times with RTEMS_DEBUG enabled. struct thread *td = NULL;
*/ int eno;
_Thread_Disable_dispatch();
away = _Workspace_Allocate(take_away);
_Thread_Enable_dispatch();
eno = kthread_add( eno = kthread_add(
test_kthread_add_thread, test_kthread_add_thread,
TEST_KTHREAD_ADD, TEST_KTHREAD_ADD,
NULL, NULL,
&td, &td,
0, 0,
0, 0,
"%s", "%s",
&test_kthread_name[0] &test_kthread_name[0]
); );
_Thread_Disable_dispatch(); ok = rtems_workspace_free(away);
_Workspace_Free(away); assert(ok);
_Thread_Enable_dispatch();
if (eno == 0) { if (eno == 0) {
wait_for_worker_thread(); wait_for_worker_thread();
assert(td != NULL); assert(td != NULL);
take_away = 0; break;
} else { } else {
assert(eno == ENOMEM); assert(eno == ENOMEM);
assert(rtems_resource_snapshot_check(&snapshot)); assert(rtems_resource_snapshot_check(&snapshot));
}
--take_away;
} }
--take_away;
} }
assert(take_away > 0);
rtems_workspace_greedy_free(greedy); rtems_workspace_greedy_free(greedy);
} }