comparison packages/kernel/current/tests/ksem1.c @ 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
20 // 20 //
21 // The Original Code is eCos - Embedded Cygnus Operating System, released 21 // The Original Code is eCos - Embedded Cygnus Operating System, released
22 // September 30, 1998. 22 // September 30, 1998.
23 // 23 //
24 // The Initial Developer of the Original Code is Cygnus. Portions created 24 // The Initial Developer of the Original Code is Cygnus. Portions created
25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. 25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved.
26 // ------------------------------------------- 26 // -------------------------------------------
27 // 27 //
28 //####COPYRIGHTEND#### 28 //####COPYRIGHTEND####
29 //========================================================================== 29 //==========================================================================
30 //#####DESCRIPTIONBEGIN#### 30 //#####DESCRIPTIONBEGIN####
34 // Date: 1998-03-20 34 // Date: 1998-03-20
35 // Description: Tests basic semaphore functionality. 35 // Description: Tests basic semaphore functionality.
36 //####DESCRIPTIONEND#### 36 //####DESCRIPTIONEND####
37 */ 37 */
38 38
39 #include <cyg/hal/hal_arch.h> // CYGNUM_HAL_STACK_SIZE_TYPICAL
40
39 #include <cyg/kernel/kapi.h> 41 #include <cyg/kernel/kapi.h>
40 42
41 #include <cyg/infra/testcase.h> 43 #include <cyg/infra/testcase.h>
42 44
43 #ifdef CYGFUN_KERNEL_API_C 45 #ifdef CYGFUN_KERNEL_API_C
44 46
45 #include "testaux.h" 47 #include "testaux.h"
46 48
47 #define NTHREADS 2 49 #define NTHREADS 2
48 #define STACKSIZE 4096 50 #define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL
49 51
50 static cyg_handle_t thread[NTHREADS]; 52 static cyg_handle_t thread[NTHREADS];
51 53
52 static cyg_thread thread_obj[NTHREADS]; 54 static cyg_thread thread_obj[NTHREADS];
53 static char stack[NTHREADS][STACKSIZE]; 55 static char stack[NTHREADS][STACKSIZE];
84 CYG_TEST_PASS_FINISH("Kernel C API Semaphore 1 OK"); 86 CYG_TEST_PASS_FINISH("Kernel C API Semaphore 1 OK");
85 } 87 }
86 88
87 static void entry1( cyg_addrword_t data ) 89 static void entry1( cyg_addrword_t data )
88 { 90 {
89 cyg_ucount32 val; 91 cyg_count32 val;
90 92
91 cyg_semaphore_peek(&s1, &val); 93 cyg_semaphore_peek(&s1, &val);
92 CHECK( 2 == val); 94 CHECK( 2 == val);
93 cyg_semaphore_wait(&s1); 95 cyg_semaphore_wait(&s1);
94 cyg_semaphore_peek(&s1, &val); 96 cyg_semaphore_peek(&s1, &val);
123 cyg_semaphore_init( &s0, 0); 125 cyg_semaphore_init( &s0, 0);
124 cyg_semaphore_init( &s1, 2); 126 cyg_semaphore_init( &s1, 2);
125 cyg_semaphore_init( &s2, 0); 127 cyg_semaphore_init( &s2, 0);
126 128
127 cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "ksem1-0", 129 cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "ksem1-0",
128 (void *)stack[0], STACKSIZE,&thread[0], &thread_obj[0]); 130 (void *)stack[0], STACKSIZE,&thread[0], &thread_obj[0]);
129 cyg_thread_resume(thread[0]); 131 cyg_thread_resume(thread[0]);
130 132
131 cyg_thread_create(4, entry1 , (cyg_addrword_t)1, "ksem1-1", 133 cyg_thread_create(4, entry1 , (cyg_addrword_t)1, "ksem1-1",
132 (void *)stack[1], STACKSIZE, &thread[1], &thread_obj[1]); 134 (void *)stack[1], STACKSIZE, &thread[1], &thread_obj[1]);
133 cyg_thread_resume(thread[1]); 135 cyg_thread_resume(thread[1]);
134 136
135 cyg_scheduler_start(); 137 cyg_scheduler_start();
136 138
137 CYG_TEST_FAIL_FINISH("Not reached"); 139 CYG_TEST_FAIL_FINISH("Not reached");
147 #else /* def CYGFUN_KERNEL_API_C */ 149 #else /* def CYGFUN_KERNEL_API_C */
148 externC void 150 externC void
149 cyg_start( void ) 151 cyg_start( void )
150 { 152 {
151 CYG_TEST_INIT(); 153 CYG_TEST_INIT();
152 CYG_TEST_PASS_FINISH("Kernel C API layer disabled"); 154 CYG_TEST_NA("Kernel C API layer disabled");
153 } 155 }
154 #endif /* def CYGFUN_KERNEL_API_C */ 156 #endif /* def CYGFUN_KERNEL_API_C */
155 157
156 /* EOF ksem1.c */ 158 /* EOF ksem1.c */