ADT
arm-eh
ast-experimental
enum
forall-pointer-decay
jacob/cs343-translation
new-ast
new-ast-unique-expr
pthread-emulation
qualifiedEnum
|
Last change
on this file since 6091b88a was c701332a, checked in by Thierry Delisle <tdelisle@…>, 6 years ago |
|
Cleanup of builtin atomics to remove _1,2,4 suffix versions and support all basic ints
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | #include <kernel.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 volatile int counter = 0;
|
|---|
| 24 |
|
|---|
| 25 | thread worker_t {
|
|---|
| 26 | int value;
|
|---|
| 27 | };
|
|---|
| 28 |
|
|---|
| 29 | void ?{}( worker_t & this, int value ) {
|
|---|
| 30 | this.value = value;
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | void main(worker_t & this) {
|
|---|
| 34 | while(TEST(counter < N)) {
|
|---|
| 35 | __cfaabi_check_preemption();
|
|---|
| 36 | if( (counter % 7) == this.value ) {
|
|---|
| 37 | __cfaabi_check_preemption();
|
|---|
| 38 | int next = __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST );
|
|---|
| 39 | __cfaabi_check_preemption();
|
|---|
| 40 | if( (next % 100) == 0 ) printf("%d\n", (int)next);
|
|---|
| 41 | __cfaabi_check_preemption();
|
|---|
| 42 | }
|
|---|
| 43 | __cfaabi_check_preemption();
|
|---|
| 44 | KICK_WATCHDOG;
|
|---|
| 45 | }
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | int main(int argc, char* argv[]) {
|
|---|
| 49 | processor p;
|
|---|
| 50 | {
|
|---|
| 51 | worker_t w0 = 0;
|
|---|
| 52 | worker_t w1 = 1;
|
|---|
| 53 | worker_t w2 = 2;
|
|---|
| 54 | worker_t w3 = 3;
|
|---|
| 55 | worker_t w4 = 4;
|
|---|
| 56 | worker_t w5 = 5;
|
|---|
| 57 | worker_t w6 = 6;
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.