source: rtems/testsuites/samples/unlimited/init.c @ 5f0cd34

4.11
Last change on this file since 5f0cd34 was 5f0cd34, checked in by Joel Sherrill <joel.sherrill@…>, on May 12, 2012 at 4:12:57 PM

samples - Eliminate missing prototype warnings

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define CONFIGURE_INIT
15
16#include "system.h"
17#include "tmacros.h"
18#include <stdio.h>
19#include <stdlib.h>
20
21rtems_id task_id[MAX_TASKS];
22
23rtems_task Init(
24  rtems_task_argument ignored
25)
26{
27  rtems_task_priority old_priority;
28  rtems_mode          old_mode;
29  uint32_t            task;
30
31  /* lower the task priority to allow created tasks to execute */
32
33  rtems_task_set_priority(
34    RTEMS_SELF, RTEMS_MAXIMUM_PRIORITY - 1, &old_priority);
35  rtems_task_mode(RTEMS_PREEMPT,  RTEMS_PREEMPT_MASK, &old_mode);
36
37  printf( "\n*** UNLIMITED TASK TEST ***\n" );
38
39  /*
40   * Invalid state if the task id is 0
41   */
42
43  for (task = 0; task < MAX_TASKS; task++)
44    task_id[task] = 0;
45
46  test1();
47  test2();
48  test3();
49
50  printf( "\n*** END OF UNLIMITED TASK TEST ***\n" );
51  exit( 0 );
52}
53
54rtems_task test_task(
55  rtems_task_argument my_number
56  )
57{
58  rtems_event_set out;
59
60  printf( "task %" PRIdrtems_task_argument " has started.\n",  my_number);
61
62  rtems_event_receive(1, RTEMS_WAIT | RTEMS_EVENT_ANY, 0, &out);
63
64  printf( "task %" PRIdrtems_task_argument " ending.\n",  my_number);
65
66  rtems_task_delete(RTEMS_SELF);
67}
68
69void destory_all_tasks(
70  const char *who
71)
72{
73  uint32_t   task;
74
75  /*
76   *  If the id is not zero, signal the task to delete.
77   */
78
79  for (task = 0; task < MAX_TASKS; task++)
80    if (task_id[task])
81    {
82      printf(" %s : signal task %08" PRIxrtems_id " to delete, ", who, task_id[task]);
83      fflush(stdout);
84      rtems_event_send(task_id[task], 1);
85      task_id[task] = 0;
86    }
87}
88
89bool status_code_bad(
90  rtems_status_code status_code
91  )
92{
93  if (status_code != RTEMS_SUCCESSFUL)
94  {
95    printf("failure, ");
96
97    if (status_code == RTEMS_TOO_MANY)
98    {
99      printf("too many.\n");
100      return TRUE;
101    }
102    if (status_code == RTEMS_UNSATISFIED)
103    {
104      printf("unsatisfied.\n");
105      return TRUE;
106    }
107
108    printf("error code = %i\n", status_code);
109    exit( 1 );
110  }
111  return FALSE;
112}
Note: See TracBrowser for help on using the repository browser.