ADTast-experimentalenumpthread-emulationqualifiedEnum
Last change
on this file since 891f707 was
fc72696c,
checked in by Thierry Delisle <tdelisle@…>, 3 years ago
|
Added second preempt test that checks the same thing but using a different technique
|
-
Property mode set to
100644
|
File size:
743 bytes
|
Line | |
---|
1 | #include <fstream.hfa> |
---|
2 | #include <thread.hfa> |
---|
3 | #include <time.hfa> |
---|
4 | |
---|
5 | #include "long_tests.hfa" |
---|
6 | |
---|
7 | #ifndef PREEMPTION_RATE |
---|
8 | #define PREEMPTION_RATE 10`ms |
---|
9 | #endif |
---|
10 | |
---|
11 | Duration default_preemption() { |
---|
12 | return PREEMPTION_RATE; |
---|
13 | } |
---|
14 | |
---|
15 | #ifdef TEST_LONG |
---|
16 | static const unsigned long N = 30_000ul; |
---|
17 | #else |
---|
18 | static const unsigned long N = 500ul; |
---|
19 | #endif |
---|
20 | |
---|
21 | extern void __cfaabi_check_preemption(); |
---|
22 | |
---|
23 | static struct { |
---|
24 | volatile int x; |
---|
25 | volatile int y; |
---|
26 | } globals; |
---|
27 | |
---|
28 | thread T1 {}; |
---|
29 | void main(T1 &) { |
---|
30 | for() { |
---|
31 | if ( globals.x == N ) break; |
---|
32 | if ( globals.x < globals.y ) globals.x += 1; |
---|
33 | } |
---|
34 | } |
---|
35 | |
---|
36 | thread T2 {}; |
---|
37 | void main(T2 &) { |
---|
38 | for() { |
---|
39 | if ( globals.y == N ) break; |
---|
40 | if ( globals.y == globals.x ) globals.y += 1; |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | int main() { |
---|
45 | { |
---|
46 | T1 t1; |
---|
47 | T2 t2; |
---|
48 | } |
---|
49 | sout | "Done"; |
---|
50 | } // main |
---|
Note: See
TracBrowser
for help on using the repository browser.