source: src/tests/concurrent/coroutineYield.c @ d35e796

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumwith_gc
Last change on this file since d35e796 was 7bdcac1, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

Added the option to make longrun tests run until failure

  • Property mode set to 100644
File size: 699 bytes
RevLine 
[82c948c]1#include <fstream>
2#include <kernel>
3#include <stdlib>
4#include <thread>
[b9da9585]5#include <time>
6
[7bdcac1]7#include "long_tests.h"
8
[b9da9585]9#ifndef PREEMPTION_RATE
10#define PREEMPTION_RATE 10`ms
11#endif
12
13Duration default_preemption() {
14        return PREEMPTION_RATE;
15}
[82c948c]16
[7bdcac1]17#ifdef TEST_LONG
[70969f8]18static const unsigned long N = 600_000ul;
19#else
20static const unsigned long N = 1_000ul;
21#endif
22
[82c948c]23coroutine Coroutine {};
24
25void main(Coroutine& this) {
[7323573]26        while(true) {
27                sout | "Coroutine 1" | endl;
28                yield();
29                sout | "Coroutine 2" | endl;
30                suspend();
31        }
[82c948c]32}
33
34
35int main(int argc, char* argv[]) {
36        Coroutine c;
[7bdcac1]37        for(int i = 0; TEST(i < N); i++) {
[7323573]38                sout | "Thread 1" | endl;
39                resume(c);
40                sout | "Thread 2" | endl;
41                yield();
[7bdcac1]42                KICK_WATCHDOG;
[7323573]43        }
[82c948c]44}
Note: See TracBrowser for help on using the repository browser.