source: doc/theses/thierry_delisle_PhD/code/readyQ_proto/processor.hpp @ f9f3775

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since f9f3775 was f9f3775, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Moved phd code for the readQ prototype to it's own folder

  • Property mode set to 100644
File size: 627 bytes
Line 
1#include <atomic>
2
3struct thread {};
4
5struct cluster {
6        void add();
7        void remove();
8        thread * next();
9};
10
11struct processor {
12
13        cluster cluster;
14        std::atomic<bool> stop;
15        volatile bool idle;
16};
17
18
19void run(thread * ) {
20        // verify preemption
21
22        // run Thread
23
24        // verify preemption
25
26        // finish Running
27}
28
29void main(processor & self) {
30
31        self.cluster.add();
32
33        while(!self.stop) {
34                if(thread * t = self.cluster.next()) {
35                        run(t);
36                        continue;
37                }
38
39                self.set_idle();
40                std::atomic_thread_fence();
41
42                if(thread * t = self.cluster.next()) {
43                        self.idle = false;
44                        run(t);
45                        continue;
46                }
47
48                halt();
49        }
50
51        self.cluster.remove();
52
53}
Note: See TracBrowser for help on using the repository browser.