source: rtems/c/src/tests/samples/unlimited/test1.c @ f59df6b2

4.104.114.84.95
Last change on this file since f59df6b2 was f59df6b2, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 2, 1999 at 3:19:43 PM

Modified to use minimum stack size and reserve the necessary amount
of space in the workspace.

  • Property mode set to 100644
File size: 2.6 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 *  Copyright assigned to U.S. Government, 1994.
13 *
14 *  The license and distribution terms for this file may in
15 *  the file LICENSE in this distribution or at
16 *  http://www.OARcorp.com/rtems/license.html.
17 *
18 *  $Id$
19 */
20
21#include "system.h"
22#include <rtems/score/object.h>
23#include <stdio.h>
24
25void test1()
26{
27  boolean           auto_extend;
28  rtems_status_code result;
29  rtems_unsigned32  task_count = 0;
30 
31  char              c1 = 'a';
32  char              c2 = 'a';
33  char              c3 = '0';
34  char              c4 = '0';
35   
36  printf( "\n TEST1 : auto-extend disabled.\n" );
37
38  /*
39   * This is a major hack and only recommended for a test. Doing this
40   * saves having another test.
41   */
42
43  auto_extend = _Objects_Information_table[OBJECTS_RTEMS_TASKS]->auto_extend;
44  _Objects_Information_table[OBJECTS_RTEMS_TASKS]->auto_extend = FALSE;
45 
46  while (task_count < MAX_TASKS)
47  {
48    rtems_name name;
49
50    printf(" TEST1 : creating task '%c%c%c%c', ", c1, c2, c3, c4);
51   
52    name = rtems_build_name(c1, c2, c3, c4);
53
54    result = rtems_task_create(name,
55                               10,
56                               RTEMS_MINIMUM_STACK_SIZE,
57                               RTEMS_DEFAULT_ATTRIBUTES,
58                               RTEMS_LOCAL,
59                               &task_id[task_count]);
60
61    if (status_code_bad(result))
62      break;
63   
64    printf("number = %3i, id = %08x, starting, ", task_count, task_id[task_count]);
65   
66    fflush(stdout);
67    result = rtems_task_start(task_id[task_count],
68                              test_task,
69                              (rtems_task_argument) task_count);
70   
71    if (status_code_bad(result))
72      break;
73   
74    /*
75     *  Update the name.
76     */
77   
78    NEXT_TASK_NAME(c1, c2, c3, c4);
79   
80    task_count++;
81  }
82
83  if (task_count >= MAX_TASKS)
84    printf( "\nMAX_TASKS too small for work-space size, please make larger !!\n\n" );
85   
86  if (task_count != (TASK_ALLOCATION_SIZE - 1)) {
87    printf( " FAIL1 : the number of tasks does not equal the expected size -\n"
88            "           task created = %i, required number = %i\n",
89            task_count, TASK_ALLOCATION_SIZE);
90    exit( 1 );
91  }
92
93  destory_all_tasks("TEST1");
94 
95  _Objects_Information_table[OBJECTS_RTEMS_TASKS]->auto_extend = auto_extend;
96 
97  printf( " TEST1 : completed\n" );
98}
99
100
101
102
103
Note: See TracBrowser for help on using the repository browser.