source: src/tests/preempt_longrun/yield.c@ ca54499

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum with_gc
Last change on this file since ca54499 was 8ad6533, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

remove cfatime.h, move itimerval constructor to "time", update concurrent examples to use Duration

  • Property mode set to 100644
File size: 505 bytes
RevLine 
[cc3e4d0]1#include <kernel>
2#include <thread>
3
[70969f8]4#ifdef LONG_TEST
5static const unsigned long N = 9_750_000ul;
6#else
[cd99ef1]7static const unsigned long N = 325_000ul;
[70969f8]8#endif
[cd99ef1]9
[cc3e4d0]10#ifndef PREEMPTION_RATE
[8ad6533]11#define PREEMPTION_RATE 10`ms
[cc3e4d0]12#endif
13
[8ad6533]14Duration default_preemption() {
[cc3e4d0]15 return PREEMPTION_RATE;
16}
17
[0322865c]18thread worker_t {};
[cc3e4d0]19
[1449d83]20void main(worker_t & this) {
[cd99ef1]21 for(int i = 0; i < N; i++) {
[cc3e4d0]22 yield();
23 }
24}
25
[0322865c]26extern "C" {
27static worker_t * workers;
28}
29
[cc3e4d0]30int main(int argc, char* argv[]) {
31 processor p;
32 {
[0322865c]33 worker_t w[7];
34 workers = w;
[cc3e4d0]35 }
[1449d83]36}
Note: See TracBrowser for help on using the repository browser.