source: rtems/testsuites/samples/unlimited/test1.c @ d252e20a

5
Last change on this file since d252e20a was d252e20a, checked in by Sebastian Huber <sebastian.huber@…>, on 12/10/19 at 10:13:18

score: Simplify _Thread_Initialize()

Allocate new thread queue heads during objects information extend. This
removes an error case and the last dependency on the workspace in
_Thread_Initialize().

Update #3835.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*  Test1
2 *
3 *  This test uses a hack to disable suto-extend then checks to see only the
4 *  requested number of objects are allocated.
5 *
6 *  Input parameters:  NONE
7 *
8 *  Output parameters:  NONE
9 *
10 *  COPYRIGHT (c) 1989-1997.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may in
14 *  the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#ifdef HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <inttypes.h>
23#include <stdio.h>
24#include <stdlib.h>
25
26#include "system.h"
27#include "tmacros.h"
28
29#include <rtems/score/objectimpl.h>
30
31void test1()
32{
33  Objects_Maximum      objects_per_block;
34  rtems_status_code    result;
35  uint32_t             task_count = 0;
36  Objects_Information *the_information;
37
38  char              c1 = 'a';
39  char              c2 = 'a';
40  char              c3 = '0';
41  char              c4 = '0';
42
43  printf( "\n TEST1 : auto-extend disabled.\n" );
44
45  /*
46   * This is a major hack and only recommended for a test. Doing this
47   * saves having another test.
48   */
49
50  the_information =
51    _Objects_Information_table[OBJECTS_CLASSIC_API][OBJECTS_RTEMS_TASKS];
52  objects_per_block = the_information->objects_per_block;
53  the_information->objects_per_block = 0;
54  the_information->allocate = _Objects_Allocate_static;
55
56  while (task_count < MAX_TASKS)
57  {
58    rtems_name name;
59
60    printf(" TEST1 : 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                               RTEMS_MINIMUM_STACK_SIZE,
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 = %3" PRIi32 ", id = %08" PRIxrtems_id ", starting, ", task_count, task_id[task_count]);
75
76    fflush(stdout);
77    result = rtems_task_start(task_id[task_count],
78                              test_task,
79                              (rtems_task_argument) task_count);
80
81    if (status_code_bad(result))
82      break;
83
84    /*
85     *  Update the name.
86     */
87
88    NEXT_TASK_NAME(c1, c2, c3, c4);
89
90    task_count++;
91  }
92
93  if (task_count >= MAX_TASKS)
94    printf( "\nMAX_TASKS too small for work-space size, please make larger !!\n\n" );
95
96  if (task_count != (TASK_ALLOCATION_SIZE - 1)) {
97    printf( " FAIL1 : the number of tasks does not equal the expected size -\n"
98            "           task created = %" PRIi32 ", required number = %i\n",
99            task_count, TASK_ALLOCATION_SIZE);
100    exit( 1 );
101  }
102
103  destroy_all_tasks("TEST1");
104
105  the_information->objects_per_block = objects_per_block;
106  the_information->allocate = _Thread_Allocate_unlimited;
107
108  printf( " TEST1 : completed\n" );
109}
Note: See TracBrowser for help on using the repository browser.