source: rtems/testsuites/samples/unlimited/init.c @ 05e3b5b

4.104.114.84.95
Last change on this file since 05e3b5b was 05e3b5b, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/01 at 21:02:52

2001-10-12 Joel Sherrill <joel@…>

  • unlimited/init.c, unlimited/system.h, unlimited/test1.c, unlimited/test2.c, unlimited/test3.c, unlimited/unlimited.doc: Fixed typo.
  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*  Init
2 *
3 *  This routine is the initialization task for this test program.
4 *  It is called from init_exec and has the responsibility for creating
5 *  and starting the tasks that make up the test.  If the time of day
6 *  clock is required for the test, it should also be set to a known
7 *  value by this function.
8 *
9 *  Input parameters:  NONE
10 *
11 *  Output parameters:  NONE
12 *
13 *  COPYRIGHT (c) 1989-1997.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 *  The license and distribution terms for this file may in
17 *  the file LICENSE in this distribution or at
18 *  http://www.OARcorp.com/rtems/license.html.
19 *
20 *  $Id$
21 */
22
23#define CONFIGURE_INIT
24
25#include "system.h"
26#include <stdio.h>
27
28rtems_id task_id[MAX_TASKS];
29
30void test1();
31void test2();
32
33rtems_task Init(
34  rtems_task_argument ignored
35)
36{
37  rtems_task_priority old_priority;
38  rtems_mode          old_mode;
39  rtems_unsigned32    task;
40
41  /* lower the task priority to allow created tasks to execute */
42 
43  rtems_task_set_priority(RTEMS_SELF, 20, &old_priority);
44  rtems_task_mode(RTEMS_PREEMPT,  RTEMS_PREEMPT_MASK, &old_mode);
45 
46  printf( "\n*** UNLIMITED TASK TEST ***\n" );
47
48  /*
49   * Invalid state if the task id is 0
50   */
51   
52  for (task = 0; task < MAX_TASKS; task++)
53    task_id[task] = 0;
54
55  test1();
56  test2();
57  test3();
58 
59  printf( "\n*** END OF UNLIMITED TASK TEST ***\n" );
60  exit( 0 );
61}
62
63rtems_task test_task(
64  rtems_task_argument my_number
65  )
66{
67  rtems_event_set out;
68 
69  printf( "task %i has started.\n",  my_number);
70
71  rtems_event_receive(1, RTEMS_WAIT | RTEMS_EVENT_ANY, 0, &out);
72 
73  printf( "task %i ending.\n",  my_number);
74
75  rtems_task_delete(RTEMS_SELF);
76}
77
78void destory_all_tasks(
79  const char *who
80)
81{
82  rtems_unsigned32 task;
83 
84  /*
85   *  If the id is not zero, signal the task to delete.
86   */
87 
88  for (task = 0; task < MAX_TASKS; task++)
89    if (task_id[task])
90    {
91      printf(" %s : signal task %08x to delete, ", who, task_id[task]);
92      fflush(stdout);
93      rtems_event_send(task_id[task], 1);
94      task_id[task] = 0;
95    }
96}
97
98boolean status_code_bad(
99  rtems_status_code status_code
100  )
101{
102  if (status_code != RTEMS_SUCCESSFUL)
103  {
104    printf("failure, ");
105   
106    if (status_code == RTEMS_TOO_MANY)
107    {
108      printf("too many.\n");     
109      return TRUE;
110    }
111    if (status_code == RTEMS_UNSATISFIED)
112    {
113      printf("unsatisfied.\n");     
114      return TRUE;
115    }
116
117    printf("error code = %i\n", status_code);
118    exit( 1 );
119  }
120  return FALSE;
121}
122
123
124
125
126
Note: See TracBrowser for help on using the repository browser.