annotate packages/kernel/current/tests/sync3.cxx @ 3292:7f8e529b4d82 default tip

Fix FREESCALE_EDMA_NBYTES_MLOFFYES_MLOFF() so it works with negative offsets.
author vae
date Wed, 29 Apr 2015 23:31:48 +0000
parents 74dbf4c3f2e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
1 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
2 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
3 // sync3.cxx
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
4 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
5 // Sync test 3 -- tests priorities and priority inheritance
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
6 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
7 //==========================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
8 // ####ECOSGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
9 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 177
diff changeset
12 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
13 // eCos is free software; you can redistribute it and/or modify it under
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
14 // the terms of the GNU General Public License as published by the Free
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
15 // Software Foundation; either version 2 or (at your option) any later
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
16 // version.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 177
diff changeset
17 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
18 // eCos is distributed in the hope that it will be useful, but WITHOUT
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
21 // for more details.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 177
diff changeset
22 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
23 // You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
24 // along with eCos; if not, write to the Free Software Foundation, Inc.,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 177
diff changeset
26 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
27 // As a special exception, if other files instantiate templates or use
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
28 // macros or inline functions from this file, or you compile this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
29 // and link it with other works to produce a work based on this file,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
30 // this file does not by itself cause the resulting work to be covered by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
31 // the GNU General Public License. However the source code for this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
32 // must still be made available in accordance with section (3) of the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
33 // General Public License v2.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 177
diff changeset
34 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
35 // This exception does not invalidate any other reasons why a work based
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
36 // on this file might be covered by the GNU General Public License.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
37 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1507
diff changeset
38 // ####ECOSGPLCOPYRIGHTEND####
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
39 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
40 //#####DESCRIPTIONBEGIN####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
41 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
42 // Author(s): dsm
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
43 // Contributors: dsm
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
44 // Date: 1998-02-18
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
45 // Description:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
46 // Creates mutexes and threads to set up starvation condition.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
47 // Checks simple priority inheritance cures this.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
48 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
49 // The starvation condition is caused by the highest priority
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
50 // thread, t0 waiting on a mutex which is never released because
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
51 // it is held by t2. t2 never releases it because t1 will be
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
52 // running at a priority level higher than t2 (but lower than t0).
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
53 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
54 // With priority inheritance enabled, t2 will inherit its priority
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
55 // from t0 when t0 tries to grab the mutex.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
56 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
57 // Options:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
58 // CYGIMP_THREAD_PRIORITY
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
59 // CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
60 // CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_SIMPLE
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
61 //####DESCRIPTIONEND####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
62
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
63 #include <pkgconf/kernel.h>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
64
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
65 #include <cyg/kernel/thread.hxx>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
66 #include <cyg/kernel/thread.inl>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
67 #include <cyg/kernel/sched.hxx>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
68 #include <cyg/kernel/mutex.hxx>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
69 #include <cyg/kernel/sema.hxx>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
70
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
71 #include <cyg/infra/testcase.h>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
72
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
73 #include <cyg/kernel/sched.inl>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
74
177
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
75 #if defined(CYGIMP_THREAD_PRIORITY) && \
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
76 !defined(CYGPKG_KERNEL_SMP_SUPPORT)
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
77
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
78 // ------------------------------------------------------------------------
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
79 // Manufacture a simpler feature test macro for priority inheritance than
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
80 // the configuration gives us. We have priority inheritance if it is configured
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
81 // as the only protocol, or if it is the default protocol for dynamic protocol
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
82 // choice.
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
83 // FIXME: If we have dynamic protocol choice, we can also set priority inheritance
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
84 // as the protocol to be used on the mutexes we are interested in. At present we
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
85 // do not do this.
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
86
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
87 #ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
88 # ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
89 # ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_INHERIT
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
90 # define PRIORITY_INHERITANCE
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
91 # else
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
92 # undef PRIORITY_INHERITANCE
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
93 # endif
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
94 # else
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
95 # define PRIORITY_INHERITANCE
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
96 # endif
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
97 #else
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
98 # undef PRIORITY_INHERITANCE
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
99 #endif
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
100
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
101 // ------------------------------------------------------------------------
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
102
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
103 #define NTHREADS 3
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
104
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
105 #include "testaux.hxx"
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
106
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
107 static Cyg_Mutex m0;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
108 static Cyg_Binary_Semaphore s0, s1, s2;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
109
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
110 static cyg_ucount8 m0d = 9;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
111
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
112 static void check_priorities_normal()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
113 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
114 CHECK( 5 == thread[0]->get_priority());
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
115 CHECK( 6 == thread[1]->get_priority());
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
116 CHECK( 7 == thread[2]->get_priority());
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
117 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
118
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
119 static void check_priorities_inherited()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
120 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
121 CHECK( 5 == thread[0]->get_priority());
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
122 CHECK( 6 == thread[1]->get_priority());
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
123 #ifdef PRIORITY_INHERITANCE
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
124 CHECK( 5 == thread[2]->get_current_priority());
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
125 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
126 CHECK( 7 == thread[2]->get_priority());
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
127
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
128 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
129
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
130 static void entry0( CYG_ADDRWORD data )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
131 {
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
132 s0.wait(); // wait until t2 has gained m0.lock
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
133 check_priorities_normal();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
134 m0.lock(); {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
135 check_priorities_normal();
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
136 CHECK( 2 == m0d );
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
137 m0d = 0;
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
138 } m0.unlock();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
139 check_priorities_normal();
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
140 #ifdef PRIORITY_INHERITANCE
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
141 CYG_TEST_PASS_FINISH("Sync 3 OK -- priority inheritance worked");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
142 #else
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
143 CYG_TEST_FAIL_FINISH("Sync 3: thread not starved");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
144 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
145 // NOT REACHED
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
146 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
147
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
148 static void entry1( CYG_ADDRWORD data )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
149 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
150 s1.wait();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
151 // The delay below will allow testing of the priority inheritance
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
152 // mechanism when scheduler does not guarantee to schedule threads
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
153 // in strict priority order.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
154 for ( volatile cyg_ucount32 i=0; i < 100000; i++ )
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
155 ; // math is hard
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
156
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
157 #ifdef PRIORITY_INHERITANCE
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
158 // thread0 should have stopped by this point
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
159 CYG_TEST_FAIL_FINISH("Sync 3: priority inheritance mechanism failed");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
160 #else
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
161 // With strict priority scheduling and no priority inheritance
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
162 // this is expected to happen.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
163 CYG_TEST_PASS_FINISH("Sync 3 OK");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
164 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
165 CYG_TEST_FAIL_FINISH("Not reached");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
166 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
167
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
168 void entry2( CYG_ADDRWORD data )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
169 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
170 m0.lock(); {
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
171 CHECK( 9 == m0d );
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
172 check_priorities_normal();
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
173 s0.post(); // Now I have lock on m0, wake t0 then t1
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
174 check_priorities_inherited();
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
175 s1.post();
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
176 check_priorities_inherited();
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
177 m0d = 2;
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
178 } m0.unlock();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
179 check_priorities_normal();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
180 m0.lock(); {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
181 check_priorities_normal();
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
182 CHECK( 0 == m0d );
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
183 m0d = 21;
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
184 s2.wait(); // never posted
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
185 } m0.unlock();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
186 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
187
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
188
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
189
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
190 void sync3_main(void)
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
191 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
192 CYG_TEST_INIT();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
193
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
194 new_thread( entry0, 0);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
195 new_thread( entry1, 1);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
196 new_thread( entry2, 2);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
197
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
198 thread[0]->set_priority(5);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
199 thread[1]->set_priority(6);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
200 thread[2]->set_priority(7);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
201
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
202 Cyg_Scheduler::start();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
203
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
204 CYG_TEST_FAIL_FINISH("Not reached");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
205 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
206
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
207 externC void
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
208 cyg_start( void )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
209 {
130
eb9fd8c04db3 Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents: 115
diff changeset
210 #ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
eb9fd8c04db3 Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents: 115
diff changeset
211 cyg_hal_invoke_constructors();
eb9fd8c04db3 Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents: 115
diff changeset
212 #endif
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
213 sync3_main();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
214 }
177
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
215
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
216 #else // defined(CYGIMP_THREAD_PRIORITY) etc
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
217
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
218 externC void
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
219 cyg_start( void )
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
220 {
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
221 CYG_TEST_INIT();
1507
92cf4ff674de * tests/kmutex3.c (cyg_start): Use CYG_TEST_NA.
jlarmour
parents: 210
diff changeset
222 CYG_TEST_INFO("Sync3 test requires:\n"
177
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
223 "defined(CYGIMP_THREAD_PRIORITY) &&\n"
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
224 "!defined(CYGPKG_KERNEL_SMP_SUPPORT)\n");
1507
92cf4ff674de * tests/kmutex3.c (cyg_start): Use CYG_TEST_NA.
jlarmour
parents: 210
diff changeset
225 CYG_TEST_NA("Sync3 test requirements");
177
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
226
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
227 }
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
228
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
229 #endif // defined(CYGIMP_THREAD_PRIORITY) etc
4c750ce71ae3 Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents: 130
diff changeset
230
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
231 // EOF sync3.cxx