File indexing completed on 2025-05-11 08:24:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 #ifdef HAVE_CONFIG_H
0041 #include "config.h"
0042 #endif
0043
0044 #include <inttypes.h>
0045 #include <stdio.h>
0046 #include <stdlib.h>
0047 #include "system.h"
0048 #include "tmacros.h"
0049
0050 void test3()
0051 {
0052 rtems_status_code result;
0053 uint32_t remove_task;
0054 uint32_t block;
0055 uint32_t task_count = 0;
0056
0057 char c1 = 'a';
0058 char c2 = 'a';
0059 char c3 = '0';
0060 char c4 = '0';
0061
0062 printf( "\n TEST3 : free more than 3 x allocation size, but not the same block,\n"
0063 " then free a block\n");
0064
0065
0066
0067
0068
0069 if (TASK_ALLOCATION_SIZE < 4)
0070 {
0071 printf( " FAIL3 : task allocation size must be greater than 4.\n");
0072 exit( 1 );
0073 }
0074
0075
0076
0077
0078
0079 while (task_count < MAX_TASKS)
0080 {
0081 rtems_name name;
0082
0083 printf(" TEST3 : creating task '%c%c%c%c', ", c1, c2, c3, c4);
0084
0085 name = rtems_build_name(c1, c2, c3, c4);
0086
0087 result = rtems_task_create(name,
0088 10,
0089 RTEMS_MINIMUM_STACK_SIZE,
0090 RTEMS_DEFAULT_ATTRIBUTES,
0091 RTEMS_LOCAL,
0092 &task_id[task_count]);
0093
0094 if (status_code_bad(result))
0095 break;
0096
0097 printf("number = %3" PRIi32 ", id = %08" PRIxrtems_id ", starting, ", task_count, task_id[task_count]);
0098 fflush(stdout);
0099
0100 result = rtems_task_start(task_id[task_count],
0101 test_task,
0102 (rtems_task_argument) task_count);
0103
0104 if (status_code_bad(result))
0105 break;
0106
0107
0108
0109
0110
0111 NEXT_TASK_NAME(c1, c2, c3, c4);
0112
0113 task_count++;
0114 }
0115
0116
0117
0118
0119
0120
0121 if (task_count < (TASK_ALLOCATION_SIZE * 11))
0122 {
0123 printf( " FAIL3 : not enough tasks created -\n"
0124 " task created = %" PRIi32 ", required number = %i\n",
0125 task_count, (TASK_ALLOCATION_SIZE * 11));
0126 exit( 1 );
0127 }
0128
0129 for (block = 0; block < TASK_ALLOCATION_SIZE; block++)
0130 {
0131 for (remove_task = ((block * TASK_ALLOCATION_SIZE) - TASK_INDEX_OFFSET);
0132 remove_task < (((block * TASK_ALLOCATION_SIZE) + 3) - TASK_INDEX_OFFSET);
0133 remove_task++)
0134 {
0135 if (!task_id[remove_task])
0136 {
0137 printf( " FAIL3 : remove task has a 0 id -\n"
0138 " task number = %" PRIi32 "\n",
0139 remove_task);
0140 exit( 1 );
0141 }
0142
0143 printf(" TEST3 : remove, signal task %08" PRIxrtems_id ", ", task_id[remove_task]);
0144 rtems_event_send(task_id[remove_task], 1);
0145 task_id[remove_task] = 0;
0146 }
0147 }
0148
0149
0150
0151
0152
0153
0154 for (remove_task = (TASK_ALLOCATION_SIZE - TASK_INDEX_OFFSET);
0155 remove_task < ((TASK_ALLOCATION_SIZE * 2) - - TASK_INDEX_OFFSET);
0156 remove_task++)
0157 {
0158 if (task_id[remove_task])
0159 {
0160 printf(" TEST3 : remove, signal task %08" PRIxrtems_id ", ", task_id[remove_task]);
0161 rtems_event_send(task_id[remove_task], 1);
0162 task_id[remove_task] = 0;
0163 }
0164 }
0165
0166 destroy_all_tasks("TEST3");
0167
0168 printf( " TEST3 : completed\n" );
0169 }