|
0
|
1 //========================================================================== |
|
|
2 // |
|
|
3 // release.cxx |
|
|
4 // |
|
|
5 // Thread release test |
|
|
6 // |
|
|
7 //========================================================================== |
|
|
8 //####COPYRIGHTBEGIN#### |
|
|
9 // |
|
|
10 // ------------------------------------------- |
|
|
11 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
12 // Version 1.0 (the "License"); you may not use this file except in |
|
|
13 // compliance with the License. You may obtain a copy of the License at |
|
|
14 // http://sourceware.cygnus.com/ecos |
|
|
15 // |
|
|
16 // Software distributed under the License is distributed on an "AS IS" |
|
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
18 // License for the specific language governing rights and limitations under |
|
|
19 // the License. |
|
|
20 // |
|
|
21 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
22 // September 30, 1998. |
|
|
23 // |
|
|
24 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
|
25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. |
|
|
26 // ------------------------------------------- |
|
|
27 // |
|
|
28 //####COPYRIGHTEND#### |
|
|
29 //========================================================================== |
|
|
30 //#####DESCRIPTIONBEGIN#### |
|
|
31 // |
|
|
32 // Author(s): nickg |
|
|
33 // Contributors: nickg |
|
|
34 // Date: 1998-04-24 |
|
|
35 // Description: Tests the functionality of thread release(). |
|
|
36 //####DESCRIPTIONEND#### |
|
|
37 |
|
|
38 #include <pkgconf/kernel.h> |
|
|
39 |
|
|
40 #include <cyg/kernel/thread.hxx> |
|
|
41 #include <cyg/kernel/thread.inl> |
|
|
42 #include <cyg/kernel/sched.hxx> |
|
|
43 #include <cyg/kernel/mutex.hxx> |
|
|
44 #include <cyg/kernel/sema.hxx> |
|
|
45 |
|
|
46 #include <cyg/infra/testcase.h> |
|
|
47 |
|
|
48 #include <cyg/kernel/sched.inl> |
|
|
49 |
|
|
50 #define NTHREADS 2 |
|
|
51 |
|
|
52 #include "testaux.hxx" |
|
|
53 |
|
|
54 static Cyg_Binary_Semaphore s0, s1; |
|
|
55 |
|
|
56 static void entry0( CYG_ADDRWORD data ) |
|
|
57 { |
|
|
58 Cyg_Thread *self = Cyg_Thread::self(); |
|
|
59 |
|
|
60 if (!s0.wait() ) |
|
|
61 { |
|
|
62 if( self->get_wake_reason() != Cyg_Thread::BREAK ) |
|
|
63 CYG_TEST_FAIL_FINISH("Wake reason not BREAK"); |
|
|
64 } |
|
|
65 else |
|
|
66 { |
|
|
67 CYG_TEST_FAIL_FINISH("Thread not released"); |
|
|
68 } |
|
|
69 |
|
|
70 s1.post(); |
|
|
71 |
|
|
72 self->exit(); |
|
|
73 } |
|
|
74 |
|
|
75 |
|
|
76 static void entry1( CYG_ADDRWORD data ) |
|
|
77 { |
|
|
78 thread[0]->release(); |
|
|
79 |
|
|
80 s1.wait(); |
|
|
81 |
|
|
82 CYG_TEST_PASS_FINISH("Release OK"); |
|
|
83 |
|
|
84 Cyg_Thread::self()->exit(); |
|
|
85 } |
|
|
86 |
|
|
87 void release_main(void) |
|
|
88 { |
|
|
89 CYG_TEST_INIT(); |
|
|
90 |
|
|
91 new_thread( entry0, 0); |
|
|
92 new_thread( entry1, 1); |
|
|
93 |
|
|
94 thread[0]->set_priority(5); |
|
|
95 thread[1]->set_priority(6); |
|
|
96 |
|
|
97 Cyg_Scheduler::start(); |
|
|
98 |
|
|
99 CYG_TEST_FAIL_FINISH("Not reached"); |
|
|
100 |
|
|
101 } |
|
|
102 |
|
|
103 externC void |
|
|
104 cyg_start( void ) |
|
|
105 { |
|
|
106 release_main(); |
|
|
107 } |
|
|
108 |
|
|
109 // EOF release.cxx |