[dc8511c] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
| 7 | // heap.cfa -- |
---|
| 8 | // |
---|
| 9 | // Author : Peter A. Buhr |
---|
| 10 | // Created On : Tue Nov 6 17:54:56 2018 |
---|
| 11 | // Last Modified By : Peter A. Buhr |
---|
[200fcb3] | 12 | // Last Modified On : Tue Dec 11 21:52:40 2018 |
---|
| 13 | // Update Count : 18 |
---|
[dc8511c] | 14 | // |
---|
| 15 | |
---|
[73abe95] | 16 | #include <thread.hfa> |
---|
[80228a7] | 17 | #include <kernel.hfa> // processor |
---|
| 18 | #include <stdlib.hfa> // *allocs |
---|
[5d4fa18] | 19 | #include <malloc.h> // malloc_* |
---|
| 20 | |
---|
[73abe95] | 21 | // #include <time.hfa> |
---|
[5d4fa18] | 22 | // #define __CFA_DEFAULT_PREEMPTION__ 1000`us |
---|
| 23 | // //#define __CFA_DEFAULT_PREEMPTION__ 0 |
---|
| 24 | |
---|
| 25 | // Duration default_preemption() { |
---|
| 26 | // return __CFA_DEFAULT_PREEMPTION__; |
---|
| 27 | // } |
---|
| 28 | |
---|
| 29 | #define __U_DEFAULT_MMAP_START__ (512 * 1024 + 1) |
---|
| 30 | size_t default_mmap_start() __attribute__(( weak )) { |
---|
| 31 | return __U_DEFAULT_MMAP_START__; |
---|
| 32 | } // default_mmap_start |
---|
| 33 | |
---|
| 34 | thread Worker { |
---|
| 35 | }; // Worker |
---|
| 36 | |
---|
| 37 | void main( Worker & ) { |
---|
| 38 | enum { NoOfAllocs = 5000, NoOfMmaps = 10 }; |
---|
[80228a7] | 39 | char * locns[NoOfAllocs]; |
---|
[5d4fa18] | 40 | int i; |
---|
| 41 | |
---|
| 42 | // check alloc/free |
---|
| 43 | |
---|
[80228a7] | 44 | for ( j; 40 ) { |
---|
| 45 | for ( i; NoOfAllocs ) { |
---|
[5d4fa18] | 46 | locns[i] = alloc( i ); |
---|
[200fcb3] | 47 | //sout | (void *)locns[i]; |
---|
[80228a7] | 48 | for ( k; i ) locns[i][k] = '\345'; |
---|
[5d4fa18] | 49 | } // for |
---|
[200fcb3] | 50 | //sout | (char *)sbrk(0) - start | " bytes"; |
---|
[5d4fa18] | 51 | |
---|
[80228a7] | 52 | for ( i; NoOfAllocs ) { |
---|
[200fcb3] | 53 | //sout | (void *)locns[i]; |
---|
[80228a7] | 54 | for ( k; i ) if ( locns[i][k] != '\345' ) abort( "new/delete corrupt storage1" ); |
---|
[5d4fa18] | 55 | free( locns[i] ); |
---|
| 56 | } // for |
---|
[200fcb3] | 57 | //sout | (char *)sbrk(0) - start | " bytes"; |
---|
[5d4fa18] | 58 | |
---|
[80228a7] | 59 | for ( i; NoOfAllocs ) { |
---|
[5d4fa18] | 60 | locns[i] = alloc( i ); |
---|
[200fcb3] | 61 | //sout | (void *)locns[i]; |
---|
[80228a7] | 62 | for ( k; i ) locns[i][k] = '\345'; |
---|
[5d4fa18] | 63 | } // for |
---|
[80228a7] | 64 | for ( i; NoOfAllocs - 1 -~= 0 ) { |
---|
[200fcb3] | 65 | //sout | (void *)locns[i]; |
---|
[80228a7] | 66 | for ( k; i ) if ( locns[i][k] != '\345' ) abort( "new/delete corrupt storage2" ); |
---|
[5d4fa18] | 67 | free( locns[i] ); |
---|
| 68 | } // for |
---|
| 69 | } // for |
---|
| 70 | |
---|
| 71 | // check malloc/free (sbrk) |
---|
| 72 | |
---|
[80228a7] | 73 | for ( i; NoOfAllocs ) { |
---|
[5d4fa18] | 74 | size_t s = (i + 1) * 20; |
---|
[80228a7] | 75 | char * area = (char *)malloc( s ); |
---|
[5d4fa18] | 76 | if ( area == 0 ) abort( "malloc/free out of memory" ); |
---|
| 77 | area[0] = '\345'; area[s - 1] = '\345'; // fill first/last |
---|
| 78 | area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte |
---|
| 79 | free( area ); |
---|
| 80 | } // for |
---|
| 81 | |
---|
[80228a7] | 82 | for ( i; NoOfAllocs ) { |
---|
| 83 | size_t s = i + 1; // +1 to make initialization simpler |
---|
[5d4fa18] | 84 | locns[i] = (char *)malloc( s ); |
---|
| 85 | if ( locns[i] == 0 ) abort( "malloc/free out of memory" ); |
---|
| 86 | locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last |
---|
| 87 | locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte |
---|
| 88 | } // for |
---|
[80228a7] | 89 | for ( i; NoOfAllocs ) { |
---|
[5d4fa18] | 90 | size_t s = i + 1; |
---|
| 91 | if ( locns[i][0] != '\345' || locns[i][s - 1] != '\345' || |
---|
| 92 | locns[i][malloc_usable_size( locns[i] ) - 1] != '\345' ) abort( "malloc/free corrupt storage" ); |
---|
| 93 | free( locns[i] ); |
---|
| 94 | } // for |
---|
| 95 | |
---|
| 96 | // check malloc/free (mmap) |
---|
| 97 | |
---|
[80228a7] | 98 | for ( i; NoOfMmaps ) { |
---|
| 99 | size_t s = i + default_mmap_start(); // cross over point |
---|
| 100 | char * area = (char *)malloc( s ); |
---|
[5d4fa18] | 101 | if ( area == 0 ) abort( "malloc/free out of memory" ); |
---|
| 102 | area[0] = '\345'; area[s - 1] = '\345'; // fill first/last |
---|
| 103 | area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte |
---|
| 104 | free( area ); |
---|
| 105 | } // for |
---|
| 106 | |
---|
[80228a7] | 107 | for ( i; NoOfMmaps ) { |
---|
| 108 | size_t s = i + default_mmap_start(); // cross over point |
---|
[5d4fa18] | 109 | locns[i] = (char *)malloc( s ); |
---|
| 110 | if ( locns[i] == 0 ) abort( "malloc/free out of memory" ); |
---|
| 111 | locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last |
---|
| 112 | locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte |
---|
| 113 | } // for |
---|
[80228a7] | 114 | for ( i; NoOfMmaps ) { |
---|
| 115 | size_t s = i + default_mmap_start(); // cross over point |
---|
[5d4fa18] | 116 | if ( locns[i][0] != '\345' || locns[i][s - 1] != '\345' || |
---|
| 117 | locns[i][malloc_usable_size( locns[i] ) - 1] != '\345' ) abort( "malloc/free corrupt storage" ); |
---|
| 118 | free( locns[i] ); |
---|
| 119 | } // for |
---|
| 120 | |
---|
| 121 | // check calloc/free (sbrk) |
---|
| 122 | |
---|
[80228a7] | 123 | for ( i; NoOfAllocs ) { |
---|
[5d4fa18] | 124 | size_t s = (i + 1) * 20; |
---|
[80228a7] | 125 | char * area = (char *)calloc( 5, s ); |
---|
[5d4fa18] | 126 | if ( area == 0 ) abort( "calloc/free out of memory" ); |
---|
| 127 | if ( area[0] != '\0' || area[s - 1] != '\0' || |
---|
| 128 | area[malloc_usable_size( area ) - 1] != '\0' || |
---|
| 129 | ! malloc_zero_fill( area ) ) abort( "calloc/free corrupt storage1" ); |
---|
| 130 | area[0] = '\345'; area[s - 1] = '\345'; // fill first/last |
---|
| 131 | area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte |
---|
| 132 | free( area ); |
---|
| 133 | } // for |
---|
| 134 | |
---|
[80228a7] | 135 | for ( i; NoOfAllocs ) { |
---|
[5d4fa18] | 136 | size_t s = i + 1; |
---|
| 137 | locns[i] = (char *)calloc( 5, s ); |
---|
| 138 | if ( locns[i] == 0 ) abort( "calloc/free out of memory" ); |
---|
| 139 | if ( locns[i][0] != '\0' || locns[i][s - 1] != '\0' || |
---|
| 140 | locns[i][malloc_usable_size( locns[i] ) - 1] != '\0' || |
---|
| 141 | ! malloc_zero_fill( locns[i] ) ) abort( "calloc/free corrupt storage2" ); |
---|
| 142 | locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last |
---|
| 143 | locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte |
---|
| 144 | } // for |
---|
[80228a7] | 145 | for ( i; NoOfAllocs ) { |
---|
[5d4fa18] | 146 | size_t s = i + 1; |
---|
| 147 | if ( locns[i][0] != '\345' || locns[i][s - 1] != '\345' || |
---|
| 148 | locns[i][malloc_usable_size( locns[i] ) - 1] != '\345' ) abort( "calloc/free corrupt storage3" ); |
---|
| 149 | free( locns[i] ); |
---|
| 150 | } // for |
---|
| 151 | |
---|
| 152 | // check calloc/free (mmap) |
---|
| 153 | |
---|
[80228a7] | 154 | for ( i; NoOfMmaps ) { |
---|
| 155 | size_t s = i + default_mmap_start(); // cross over point |
---|
| 156 | char * area = (char *)calloc( 1, s ); |
---|
[5d4fa18] | 157 | if ( area == 0 ) abort( "calloc/free out of memory" ); |
---|
| 158 | if ( area[0] != '\0' || area[s - 1] != '\0' ) abort( "calloc/free corrupt storage4.1" ); |
---|
| 159 | if ( area[malloc_usable_size( area ) - 1] != '\0' ) abort( "calloc/free corrupt storage4.2" ); |
---|
| 160 | if ( ! malloc_zero_fill( area ) ) abort( "calloc/free corrupt storage4.3" ); |
---|
| 161 | area[0] = '\345'; area[s - 1] = '\345'; // fill first/last |
---|
| 162 | area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte |
---|
| 163 | free( area ); |
---|
| 164 | } // for |
---|
| 165 | |
---|
[80228a7] | 166 | for ( i; NoOfMmaps ) { |
---|
| 167 | size_t s = i + default_mmap_start(); // cross over point |
---|
[5d4fa18] | 168 | locns[i] = (char *)calloc( 1, s ); |
---|
| 169 | if ( locns[i] == 0 ) abort( "calloc/free out of memory" ); |
---|
| 170 | if ( locns[i][0] != '\0' || locns[i][s - 1] != '\0' || |
---|
| 171 | locns[i][malloc_usable_size( locns[i] ) - 1] != '\0' || |
---|
| 172 | ! malloc_zero_fill( locns[i] ) ) abort( "calloc/free corrupt storage5" ); |
---|
| 173 | locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last |
---|
| 174 | locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte |
---|
| 175 | } // for |
---|
[80228a7] | 176 | for ( i; NoOfMmaps ) { |
---|
| 177 | size_t s = i + default_mmap_start(); // cross over point |
---|
[5d4fa18] | 178 | if ( locns[i][0] != '\345' || locns[i][s - 1] != '\345' || |
---|
| 179 | locns[i][malloc_usable_size( locns[i] ) - 1] != '\345' ) abort( "calloc/free corrupt storage6" ); |
---|
| 180 | free( locns[i] ); |
---|
| 181 | } // for |
---|
| 182 | |
---|
| 183 | // check memalign/free (sbrk) |
---|
| 184 | |
---|
| 185 | enum { limit = 64 * 1024 }; // check alignments up to here |
---|
| 186 | |
---|
[80228a7] | 187 | for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 |
---|
[200fcb3] | 188 | //sout | alignments[a]; |
---|
[80228a7] | 189 | for ( s; 1 ~ NoOfAllocs ) { // allocation of size 0 can return null |
---|
| 190 | char * area = (char *)memalign( a, s ); |
---|
[5d4fa18] | 191 | if ( area == 0 ) abort( "memalign/free out of memory" ); |
---|
[200fcb3] | 192 | //sout | i | " " | area; |
---|
[5d4fa18] | 193 | if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment |
---|
| 194 | abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, s, area ); |
---|
| 195 | } // if |
---|
| 196 | area[0] = '\345'; area[s - 1] = '\345'; // fill first/last byte |
---|
| 197 | area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte |
---|
| 198 | free( area ); |
---|
| 199 | } // for |
---|
| 200 | } // for |
---|
| 201 | |
---|
| 202 | // check memalign/free (mmap) |
---|
| 203 | |
---|
[80228a7] | 204 | for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 |
---|
[200fcb3] | 205 | //sout | alignments[a]; |
---|
[80228a7] | 206 | for ( i; 1 ~ NoOfMmaps ) { |
---|
| 207 | size_t s = i + default_mmap_start(); // cross over point |
---|
| 208 | char * area = (char *)memalign( a, s ); |
---|
[5d4fa18] | 209 | if ( area == 0 ) abort( "memalign/free out of memory" ); |
---|
[200fcb3] | 210 | //sout | i | " " | area; |
---|
[5d4fa18] | 211 | if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment |
---|
| 212 | abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)s, area ); |
---|
| 213 | } // if |
---|
| 214 | area[0] = '\345'; area[s - 1] = '\345'; // fill first/last byte |
---|
| 215 | area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte |
---|
| 216 | free( area ); |
---|
| 217 | } // for |
---|
| 218 | } // for |
---|
| 219 | |
---|
| 220 | // check calloc/realloc/free (sbrk) |
---|
| 221 | |
---|
[80228a7] | 222 | for ( i; 1 ~ 10_000 ~ 12 ) { |
---|
[5d4fa18] | 223 | // initial N byte allocation |
---|
[80228a7] | 224 | char * area = (char *)calloc( 5, i ); |
---|
[5d4fa18] | 225 | if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); |
---|
| 226 | if ( area[0] != '\0' || area[i - 1] != '\0' || |
---|
| 227 | area[malloc_usable_size( area ) - 1] != '\0' || |
---|
| 228 | ! malloc_zero_fill( area ) ) abort( "calloc/realloc/free corrupt storage1" ); |
---|
| 229 | |
---|
| 230 | // Do not start this loop index at 0 because realloc of 0 bytes frees the storage. |
---|
[80228a7] | 231 | for ( s; i ~ 256 * 1024 ~ 26 ) { // start at initial memory request |
---|
[5d4fa18] | 232 | area = (char *)realloc( area, s ); // attempt to reuse storage |
---|
| 233 | if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); |
---|
| 234 | if ( area[0] != '\0' || area[s - 1] != '\0' || |
---|
| 235 | area[malloc_usable_size( area ) - 1] != '\0' || |
---|
| 236 | ! malloc_zero_fill( area ) ) abort( "calloc/realloc/free corrupt storage2" ); |
---|
| 237 | } // for |
---|
| 238 | free( area ); |
---|
| 239 | } // for |
---|
| 240 | |
---|
| 241 | // check calloc/realloc/free (mmap) |
---|
| 242 | |
---|
[80228a7] | 243 | for ( i; 1 ~ 10_000 ~ 12 ) { |
---|
[5d4fa18] | 244 | // initial N byte allocation |
---|
[80228a7] | 245 | size_t s = i + default_mmap_start(); // cross over point |
---|
| 246 | char * area = (char *)calloc( 1, s ); |
---|
[5d4fa18] | 247 | if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); |
---|
| 248 | if ( area[0] != '\0' || area[s - 1] != '\0' || |
---|
| 249 | area[malloc_usable_size( area ) - 1] != '\0' || |
---|
| 250 | ! malloc_zero_fill( area ) ) abort( "calloc/realloc/free corrupt storage1" ); |
---|
| 251 | |
---|
| 252 | // Do not start this loop index at 0 because realloc of 0 bytes frees the storage. |
---|
[80228a7] | 253 | for ( r; i ~ 256 * 1024 ~ 26 ) { // start at initial memory request |
---|
| 254 | area = (char *)realloc( area, r ); // attempt to reuse storage |
---|
[5d4fa18] | 255 | if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); |
---|
| 256 | if ( area[0] != '\0' || area[r - 1] != '\0' || |
---|
| 257 | area[malloc_usable_size( area ) - 1] != '\0' || |
---|
| 258 | ! malloc_zero_fill( area ) ) abort( "calloc/realloc/free corrupt storage2" ); |
---|
| 259 | } // for |
---|
| 260 | free( area ); |
---|
| 261 | } // for |
---|
| 262 | |
---|
| 263 | // check memalign/realloc/free |
---|
| 264 | |
---|
| 265 | size_t amount = 2; |
---|
[80228a7] | 266 | for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 |
---|
[5d4fa18] | 267 | // initial N byte allocation |
---|
[80228a7] | 268 | char * area = (char *)memalign( a, amount ); // aligned N-byte allocation |
---|
[5d4fa18] | 269 | if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ? |
---|
[200fcb3] | 270 | //sout | alignments[a] | " " | area; |
---|
[5d4fa18] | 271 | if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment |
---|
| 272 | abort( "memalign/realloc/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)amount, area ); |
---|
| 273 | } // if |
---|
| 274 | area[0] = '\345'; area[amount - 2] = '\345'; // fill first/penultimate byte |
---|
| 275 | |
---|
| 276 | // Do not start this loop index at 0 because realloc of 0 bytes frees the storage. |
---|
[80228a7] | 277 | for ( s; amount ~ 256 * 1024 ) { // start at initial memory request |
---|
[5d4fa18] | 278 | if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "memalign/realloc/free corrupt storage" ); |
---|
| 279 | area = (char *)realloc( area, s ); // attempt to reuse storage |
---|
| 280 | if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ? |
---|
[200fcb3] | 281 | //sout | i | " " | area; |
---|
[5d4fa18] | 282 | if ( (size_t)area % a != 0 ) { // check for initial alignment |
---|
| 283 | abort( "memalign/realloc/free bad alignment %p", area ); |
---|
| 284 | } // if |
---|
| 285 | area[s - 1] = '\345'; // fill last byte |
---|
| 286 | } // for |
---|
| 287 | free( area ); |
---|
| 288 | } // for |
---|
| 289 | |
---|
| 290 | // check cmemalign/free |
---|
| 291 | |
---|
[80228a7] | 292 | for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 |
---|
[200fcb3] | 293 | //sout | alignments[a]; |
---|
[80228a7] | 294 | for ( s; 1 ~ limit ) { // allocation of size 0 can return null |
---|
| 295 | char * area = (char *)cmemalign( a, 1, s ); |
---|
[5d4fa18] | 296 | if ( area == 0 ) abort( "cmemalign/free out of memory" ); |
---|
[200fcb3] | 297 | //sout | i | " " | area; |
---|
[5d4fa18] | 298 | if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment |
---|
| 299 | abort( "cmemalign/free bad alignment : cmemalign(%d,%d) = %p", (int)a, s, area ); |
---|
| 300 | } // if |
---|
| 301 | if ( area[0] != '\0' || area[s - 1] != '\0' || |
---|
| 302 | area[malloc_usable_size( area ) - 1] != '\0' || |
---|
| 303 | ! malloc_zero_fill( area ) ) abort( "cmemalign/free corrupt storage" ); |
---|
| 304 | area[0] = '\345'; area[s - 1] = '\345'; // fill first/last byte |
---|
| 305 | free( area ); |
---|
| 306 | } // for |
---|
| 307 | } // for |
---|
| 308 | |
---|
| 309 | // check cmemalign/realloc/free |
---|
| 310 | |
---|
| 311 | amount = 2; |
---|
[80228a7] | 312 | for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 |
---|
[5d4fa18] | 313 | // initial N byte allocation |
---|
[80228a7] | 314 | char * area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation |
---|
[5d4fa18] | 315 | if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ? |
---|
[200fcb3] | 316 | //sout | alignments[a] | " " | area; |
---|
[5d4fa18] | 317 | if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment |
---|
| 318 | abort( "cmemalign/realloc/free bad alignment : cmemalign(%d,%d) = %p", (int)a, (int)amount, area ); |
---|
| 319 | } // if |
---|
| 320 | if ( area[0] != '\0' || area[amount - 1] != '\0' || |
---|
| 321 | area[malloc_usable_size( area ) - 1] != '\0' || |
---|
| 322 | ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc/free corrupt storage1" ); |
---|
| 323 | area[0] = '\345'; area[amount - 2] = '\345'; // fill first/penultimate byte |
---|
| 324 | |
---|
| 325 | // Do not start this loop index at 0 because realloc of 0 bytes frees the storage. |
---|
[80228a7] | 326 | for ( s; amount ~ 256 * 1024 ) { // start at initial memory request |
---|
[5d4fa18] | 327 | if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "cmemalign/realloc/free corrupt storage2" ); |
---|
| 328 | area = (char *)realloc( area, s ); // attempt to reuse storage |
---|
| 329 | if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ? |
---|
[200fcb3] | 330 | //sout | i | " " | area; |
---|
[5d4fa18] | 331 | if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment |
---|
| 332 | abort( "cmemalign/realloc/free bad alignment %p", area ); |
---|
| 333 | } // if |
---|
| 334 | if ( area[s - 1] != '\0' || area[s - 1] != '\0' || |
---|
| 335 | area[malloc_usable_size( area ) - 1] != '\0' || |
---|
| 336 | ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc/free corrupt storage3" ); |
---|
| 337 | area[s - 1] = '\345'; // fill last byte |
---|
| 338 | } // for |
---|
| 339 | free( area ); |
---|
| 340 | } // for |
---|
[200fcb3] | 341 | //sout | "worker" | thisTask() | "successful completion"; |
---|
[5d4fa18] | 342 | } // Worker main |
---|
| 343 | |
---|
| 344 | int main() { |
---|
| 345 | const unsigned int NoOfWorkers = 4; |
---|
| 346 | { |
---|
| 347 | processor processors[NoOfWorkers - 1] __attribute__(( unused )); // more than one processor |
---|
| 348 | Worker workers[NoOfWorkers] __attribute__(( unused )); |
---|
| 349 | } |
---|
| 350 | // checkFreeOn(); |
---|
| 351 | // malloc_stats(); |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | // Local Variables: // |
---|
| 355 | // tab-width: 4 // |
---|
[dc8511c] | 356 | // compile-command: "cfa -nodebug -O2 heap.cfa" // |
---|
[5d4fa18] | 357 | // End: // |
---|