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

4.104.114.84.95
Last change on this file since f4a8ee1 was f4a8ee1, checked in by Joel Sherrill <joel.sherrill@…>, on 03/17/99 at 16:01:03

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: 3.7 KB
RevLine 
[f4a8ee1]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#include "system.h"
25#include <stdio.h>
26
27void test3()
28{
29  rtems_status_code   result;
30  rtems_unsigned32    remove_task;
31  rtems_unsigned32    block;
32  rtems_unsigned32    task_count = 0;
33 
34  char               c1 = 'a';
35  char               c2 = 'a';
36  char               c3 = '0';
37  char               c4 = '0';
38 
39  printf( "\n TEST3 : free more than 3 x allocation size, but not the same block,\n"
40            "         then free a block\n");
41
42  /*
43   *  Check the value of the allocation unit
44   */
45
46  if (TASK_ALLOCATION_SIZE < 4)
47  {
48    printf( " FAIL3 : task allocation size must be greater than 4.\n");
49    exit( 1 );
50  }
51 
52   /*
53   *  Allocate as many tasks as possible.
54   */
55 
56  while (task_count < MAX_TASKS)
57  {
58    rtems_name name;
59
60    printf(" TEST3 : creating task '%c%c%c%c', ", c1, c2, c3, c4);
61   
62    name = rtems_build_name(c1, c2, c3, c4);
63
64    result = rtems_task_create(name,
65                               10,
66                               4096,
67                               RTEMS_DEFAULT_ATTRIBUTES,
68                               RTEMS_LOCAL,
69                               &task_id[task_count]);
70
71    if (status_code_bad(result))
72      break;
73   
74    printf("number = %3i, id = %08x, starting, ", task_count, task_id[task_count]);
75   
76    result = rtems_task_start(task_id[task_count],
77                              test_task,
78                              (rtems_task_argument) task_count);
79   
80    if (status_code_bad(result))
81      break;
82   
83    /*
84     *  Update the name.
85     */
86   
87    NEXT_TASK_NAME(c1, c2, c3, c4);
88   
89    task_count++;
90  }
91
92  /*
93   *  Take out 3 tasks from each block of allocated tasks. Do this for
94   *  allocation size number of blocks.
95   */
96
97  if (task_count < (TASK_ALLOCATION_SIZE * 11))
98  {
99    printf( " FAIL3 : not enough tasks created -\n"
100            "         task created = %i, required number = %i\n",
101            task_count, (TASK_ALLOCATION_SIZE * 11));
102    exit( 1 );
103  }
104
105  for (block = 0; block < TASK_ALLOCATION_SIZE; block++)
106  {
107    for (remove_task = ((block * TASK_ALLOCATION_SIZE) - TASK_INDEX_OFFSET);
108         remove_task < (((block * TASK_ALLOCATION_SIZE) + 3) - TASK_INDEX_OFFSET);
109         remove_task++)
110    {
111      if (!task_id[remove_task])
112      {
113        printf( " FAIL3 : remove task has a 0 id -\n"
114                "         task number = %i\n",
115                remove_task);
116        exit( 1 );
117      }
118
119      printf(" TEST3 : remove, signal task %08x, ", task_id[remove_task]);
120      rtems_event_send(task_id[remove_task], 1);
121      task_id[remove_task] = 0;
122    }
123  }
124
125  /*
126   *  Remove a complete block, not the first, forces a scan of the blocks in the
127   *  allocator's free routine
128   */
129   
130  for (remove_task = (TASK_ALLOCATION_SIZE - TASK_INDEX_OFFSET);
131       remove_task < ((TASK_ALLOCATION_SIZE * 2) - - TASK_INDEX_OFFSET);
132       remove_task++)
133  {
134    if (task_id[remove_task])
135    {
136      printf(" TEST3 : remove, signal task %08x, ", task_id[remove_task]);
137      rtems_event_send(task_id[remove_task], 1);
138      task_id[remove_task] = 0;
139    }
140  }
141 
142  destory_all_tasks("TEST3");
143 
144  printf( " TEST3 : completed\n" );
145}
Note: See TracBrowser for help on using the repository browser.