OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [samples/] [unlimited/] [test3.c] - Blame information for rev 389

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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: test3.c,v 1.2 2001-09-27 12:02:29 chris Exp $
22
 */
23
 
24
#include "system.h"
25
#include <stdio.h>
26
 
27
void 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
                               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 = %3i, id = %08x, starting, ", task_count, task_id[task_count]);
75
    fflush(stdout);
76
 
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
  /*
94
   *  Take out 3 tasks from each block of allocated tasks. Do this for
95
   *  allocation size number of blocks.
96
   */
97
 
98
  if (task_count < (TASK_ALLOCATION_SIZE * 11))
99
  {
100
    printf( " FAIL3 : not enough tasks created -\n"
101
            "         task created = %i, required number = %i\n",
102
            task_count, (TASK_ALLOCATION_SIZE * 11));
103
    exit( 1 );
104
  }
105
 
106
  for (block = 0; block < TASK_ALLOCATION_SIZE; block++)
107
  {
108
    for (remove_task = ((block * TASK_ALLOCATION_SIZE) - TASK_INDEX_OFFSET);
109
         remove_task < (((block * TASK_ALLOCATION_SIZE) + 3) - TASK_INDEX_OFFSET);
110
         remove_task++)
111
    {
112
      if (!task_id[remove_task])
113
      {
114
        printf( " FAIL3 : remove task has a 0 id -\n"
115
                "         task number = %i\n",
116
                remove_task);
117
        exit( 1 );
118
      }
119
 
120
      printf(" TEST3 : remove, signal task %08x, ", task_id[remove_task]);
121
      rtems_event_send(task_id[remove_task], 1);
122
      task_id[remove_task] = 0;
123
    }
124
  }
125
 
126
  /*
127
   *  Remove a complete block, not the first, forces a scan of the blocks in the
128
   *  allocator's free routine
129
   */
130
 
131
  for (remove_task = (TASK_ALLOCATION_SIZE - TASK_INDEX_OFFSET);
132
       remove_task < ((TASK_ALLOCATION_SIZE * 2) - - TASK_INDEX_OFFSET);
133
       remove_task++)
134
  {
135
    if (task_id[remove_task])
136
    {
137
      printf(" TEST3 : remove, signal task %08x, ", task_id[remove_task]);
138
      rtems_event_send(task_id[remove_task], 1);
139
      task_id[remove_task] = 0;
140
    }
141
  }
142
 
143
  destory_all_tasks("TEST3");
144
 
145
  printf( " TEST3 : completed\n" );
146
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.