source: rtems/testsuites/psxtests/psx15/init.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 * Copyright (c) 2010 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Obere Lagerstr. 30
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#ifdef HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <stdio.h>
20#include <inttypes.h>
21
22#include <rtems.h>
23
24#include "tmacros.h"
25
26/* forward declarations to avoid warnings */
27rtems_task Init(rtems_task_argument argument);
28
29/*
30 * This test case shows that post switch extension handlers must cope with
31 * already deleted resources (e.g. _POSIX_signals_Post_switch_extension()).
32 * The thread delete extensions run with thread dispatching enabled.  Only the
33 * allocation mutex is locked.
34 */
35
36static rtems_id task_0 = RTEMS_ID_NONE;
37
38static rtems_id task_1 = RTEMS_ID_NONE;
39
40static void thread_delete_hook(
41  Thread_Control *executing,
42  Thread_Control *deleted
43)
44{
45  rtems_status_code sc = RTEMS_SUCCESSFUL;
46
47  if (deleted->Object.id == task_0) {
48    rtems_task_priority old = 0;
49
50    sc = rtems_task_set_priority(task_1, 2, &old);
51    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
52  }
53}
54
55static void suicide_task(rtems_task_argument arg)
56{
57  printf("suicide task %" PRIuPTR "\n", arg);
58
59  rtems_task_delete(RTEMS_SELF);
60  rtems_test_assert(false);
61}
62
63void Init(rtems_task_argument arg)
64{
65  rtems_status_code sc = RTEMS_SUCCESSFUL;
66
67  puts("\n\n*** POSIX TEST 15 ***");
68
69  sc = rtems_task_create(
70    rtems_build_name('T', 'S', 'K', '1'),
71    5,
72    RTEMS_MINIMUM_STACK_SIZE,
73    RTEMS_DEFAULT_MODES,
74    RTEMS_DEFAULT_ATTRIBUTES,
75    &task_1
76  );
77  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
78
79  sc = rtems_task_start(task_1, suicide_task, 1);
80  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
81
82  sc = rtems_task_create(
83    rtems_build_name('T', 'S', 'K', '0'),
84    3,
85    RTEMS_MINIMUM_STACK_SIZE,
86    RTEMS_DEFAULT_MODES,
87    RTEMS_DEFAULT_ATTRIBUTES,
88    &task_0
89  );
90  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
91
92  sc = rtems_task_start(task_0, suicide_task, 0);
93  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
94
95  puts("*** END OF POSIX TEST 15 ***");
96
97  rtems_test_exit(0);
98  rtems_test_assert(false);
99}
100
101#define CONFIGURE_INIT
102
103#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
104#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
105
106#define CONFIGURE_MAXIMUM_TASKS 3
107#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
108
109#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
110
111#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_PREEMPT
112#define CONFIGURE_INIT_TASK_PRIORITY 4
113
114#define CONFIGURE_INITIAL_EXTENSIONS { .thread_delete = thread_delete_hook }
115
116#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.