Mercurial > ecos
comparison packages/kernel/current/tests/testaux.hxx @ 2:443894e2e912 ecos-v1_2_1-release
Block commit of eCos version 1.2.1
| author | jlarmour |
|---|---|
| date | Tue, 11 May 1999 12:24:34 +0000 |
| parents | 3111d98ba7b3 |
| children | c38311975d4f |
comparison
equal
deleted
inserted
replaced
| 1:72f549f0d891 | 2:443894e2e912 |
|---|---|
| 23 // | 23 // |
| 24 // The Original Code is eCos - Embedded Cygnus Operating System, released | 24 // The Original Code is eCos - Embedded Cygnus Operating System, released |
| 25 // September 30, 1998. | 25 // September 30, 1998. |
| 26 // | 26 // |
| 27 // The Initial Developer of the Original Code is Cygnus. Portions created | 27 // The Initial Developer of the Original Code is Cygnus. Portions created |
| 28 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. | 28 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
| 29 // ------------------------------------------- | 29 // ------------------------------------------- |
| 30 // | 30 // |
| 31 //####COPYRIGHTEND#### | 31 //####COPYRIGHTEND#### |
| 32 //========================================================================== | 32 //========================================================================== |
| 33 //#####DESCRIPTIONBEGIN#### | 33 //#####DESCRIPTIONBEGIN#### |
| 34 // | 34 // |
| 35 // Author(s): dsm | 35 // Author(s): dsm |
| 36 // Contributors: dsm | 36 // Contributors: dsm |
| 37 // Date: 1998-03-09 | 37 // Date: 1998-03-09 |
| 38 // Description: | 38 // Description: |
| 39 // Defines some convenience functions to get us going. In | 39 // Defines some convenience functions to get us going. In |
| 40 // particular this file reserves space for NTHREADS threads, | 40 // particular this file reserves space for NTHREADS threads, |
| 41 // which can be created by calls to aux_new_thread() | 41 // which can be created by calls to aux_new_thread() |
| 42 // It also defines a CHECK function. | 42 // It also defines a CHECK function. |
| 43 // | 43 // |
| 44 //####DESCRIPTIONEND#### | 44 //####DESCRIPTIONEND#### |
| 45 | 45 |
| 46 | |
| 47 static inline void *operator new(size_t size, void *ptr) { return ptr; }; | |
| 48 | |
| 49 | |
| 46 #ifdef NTHREADS | 50 #ifdef NTHREADS |
| 47 | 51 |
| 48 #define STACKSIZE 4096 | 52 #ifndef STACKSIZE |
| 53 #define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL | |
| 54 #endif | |
| 49 | 55 |
| 50 static Cyg_Thread *thread[NTHREADS]; | 56 static Cyg_Thread *thread[NTHREADS]; |
| 51 | 57 |
| 52 static char thread_obj[NTHREADS][sizeof(Cyg_Thread)]; | 58 typedef CYG_WORD64 CYG_ALIGNMENT_TYPE; |
| 53 static char stack[NTHREADS][STACKSIZE]; | |
| 54 | 59 |
| 55 static inline void *operator new(size_t size, void *ptr) { return ptr; }; | 60 static CYG_ALIGNMENT_TYPE thread_obj[NTHREADS] [ |
| 61 (sizeof(Cyg_Thread)+sizeof(CYG_ALIGNMENT_TYPE)-1) | |
| 62 / sizeof(CYG_ALIGNMENT_TYPE) ]; | |
| 63 | |
| 64 static CYG_ALIGNMENT_TYPE stack[NTHREADS] [ | |
| 65 (STACKSIZE+sizeof(CYG_ALIGNMENT_TYPE)-1) | |
| 66 / sizeof(CYG_ALIGNMENT_TYPE) ]; | |
| 56 | 67 |
| 57 static int nthreads = 0; | 68 static int nthreads = 0; |
| 58 | 69 |
| 59 static Cyg_Thread *new_thread(cyg_thread_entry *entry, CYG_ADDRWORD data) { | 70 static Cyg_Thread *new_thread(cyg_thread_entry *entry, CYG_ADDRWORD data) { |
| 60 | 71 |
| 61 CYG_ASSERT(nthreads < NTHREADS, | 72 CYG_ASSERT(nthreads < NTHREADS, |
| 62 "Attempt to create more than NTHREADS threads"); | 73 "Attempt to create more than NTHREADS threads"); |
| 63 | 74 |
| 64 thread[nthreads] = new( (void *)&thread_obj[nthreads] ) | 75 thread[nthreads] = new( (void *)&thread_obj[nthreads] ) |
| 65 Cyg_Thread(entry, data, STACKSIZE, (CYG_ADDRESS)stack[nthreads] ); | 76 Cyg_Thread(CYG_SCHED_DEFAULT_INFO, |
| 77 entry, data, | |
| 78 NULL, // no name | |
| 79 (CYG_ADDRESS)stack[nthreads], STACKSIZE ); | |
| 66 | 80 |
| 67 thread[nthreads]->resume(); | 81 thread[nthreads]->resume(); |
| 68 | 82 |
| 69 return thread[nthreads++]; | 83 return thread[nthreads++]; |
| 70 } | 84 } |
