source: rtems/c/src/tests/samples/unlimited/init.c @ f4a8ee1

4.104.114.84.95
Last change on this file since f4a8ee1 was f4a8ee1, checked in by Joel Sherrill <joel.sherrill@…>, on Mar 17, 1999 at 4:01:03 PM

Unlimited objects patch from Chris Johns <ccj@…>. Email follows:

First, the unlimited patch. I have compiled the unlmited patch for the
Linux posix BSP only and it seems to work cleanly. I would like a really
major application run on this change before commiting as the changes are
very core and significant. I am currently building all the tests to run.

I have no targets suitable to test on at the moment.

I have tested the patch for inline functions and macros.

Turning macros on has found some core bugs. I have fixed these but have
not run all the tests. Please review the patch for these changes. They
are:

1) The conditional compilation for MP support broke the core messages
code. You cannot embed a conditional macro in another macro. The Send
and Urgent Send calls are macros.

2) User extensions handler initialisation now has two parameters. I have
updated the macros to support the extra parameter.

The patch also contains the gcc-target-default.cfg fix required to build
the kernel. More of a by product than a fix for you.

  • Property mode set to 100644
File size: 2.5 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 *  Copyright assigned to U.S. Government, 1994.
16 *
17 *  The license and distribution terms for this file may in
18 *  the file LICENSE in this distribution or at
19 *  http://www.OARcorp.com/rtems/license.html.
20 *
21 *  $Id$
22 */
23
24#define TEST_INIT
25
26#include "system.h"
27#include <stdio.h>
28
29rtems_id task_id[MAX_TASKS];
30
31void test1();
32void test2();
33
34rtems_task Init(
35  rtems_task_argument ignored
36)
37{
38  rtems_task_priority old_priority;
39  rtems_mode          old_mode;
40  rtems_unsigned32    task;
41
42  /* lower the task priority to allow created tasks to execute */
43 
44  rtems_task_set_priority(RTEMS_SELF, 20, &old_priority);
45  rtems_task_mode(RTEMS_PREEMPT,  RTEMS_PREEMPT_MASK, &old_mode);
46 
47  printf( "\n*** UNLIMITED TASK TEST ***\n" );
48
49  /*
50   * Invalid state if the task id is 0
51   */
52   
53  for (task = 0; task < MAX_TASKS; task++)
54    task_id[task] = 0;
55
56  test1();
57  test2();
58  test3();
59 
60  printf( "\n*** END OF UNLIMITED TASK TEST ***\n" );
61  exit( 0 );
62}
63
64rtems_task test_task(
65  rtems_task_argument my_number
66  )
67{
68  rtems_event_set out;
69 
70  printf( "task %i has started.\n",  my_number);
71
72  rtems_event_receive(1, RTEMS_WAIT | RTEMS_EVENT_ANY, 0, &out);
73 
74  printf( "task %i ending.\n",  my_number);
75
76  rtems_task_delete(RTEMS_SELF);
77}
78
79void destory_all_tasks(
80  const char *who
81)
82{
83  rtems_unsigned32 task;
84 
85  /*
86   *  If the id is not zero, signal the task to delete.
87   */
88 
89  for (task = 0; task < MAX_TASKS; task++)
90    if (task_id[task])
91    {
92      printf(" %s : signal task %08x to delete, ", who, task_id[task]);
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.