1 | // -*- Mode: CFA -*-
|
---|
2 | //
|
---|
3 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
|
---|
4 | //
|
---|
5 | // The contents of this file are covered under the licence agreement in the
|
---|
6 | // file "LICENCE" distributed with Cforall.
|
---|
7 | //
|
---|
8 | // kernel --
|
---|
9 | //
|
---|
10 | // Author : Thierry Delisle
|
---|
11 | // Created On : Tue Jan 17 12:27:26 2017
|
---|
12 | // Last Modified By : Thierry Delisle
|
---|
13 | // Last Modified On : --
|
---|
14 | // Update Count : 0
|
---|
15 | //
|
---|
16 |
|
---|
17 | #ifndef KERNEL_H
|
---|
18 | #define KERNEL_H
|
---|
19 |
|
---|
20 | #include <stdbool.h>
|
---|
21 |
|
---|
22 | #include "invoke.h"
|
---|
23 |
|
---|
24 | extern "C" {
|
---|
25 | #include <pthread.h>
|
---|
26 | }
|
---|
27 |
|
---|
28 | //-----------------------------------------------------------------------------
|
---|
29 | // Locks
|
---|
30 | void lock( spinlock * );
|
---|
31 | void unlock( spinlock * );
|
---|
32 |
|
---|
33 | void wait( signal_once * );
|
---|
34 | void signal( signal_once * );
|
---|
35 |
|
---|
36 | //-----------------------------------------------------------------------------
|
---|
37 | // Cluster
|
---|
38 | struct cluster {
|
---|
39 | simple_thread_list ready_queue;
|
---|
40 | spinlock lock;
|
---|
41 | };
|
---|
42 |
|
---|
43 | void ?{}(cluster * this);
|
---|
44 | void ^?{}(cluster * this);
|
---|
45 |
|
---|
46 | //-----------------------------------------------------------------------------
|
---|
47 | // Processor
|
---|
48 | enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule };
|
---|
49 | struct FinishAction {
|
---|
50 | FinishOpCode action_code;
|
---|
51 | thread_desc * thrd;
|
---|
52 | spinlock * lock;
|
---|
53 | };
|
---|
54 | static inline void ?{}(FinishAction * this) {
|
---|
55 | this->action_code = No_Action;
|
---|
56 | this->thrd = NULL;
|
---|
57 | this->lock = NULL;
|
---|
58 | }
|
---|
59 | static inline void ^?{}(FinishAction * this) {}
|
---|
60 |
|
---|
61 | struct processor {
|
---|
62 | struct processorCtx_t * runner;
|
---|
63 | cluster * cltr;
|
---|
64 | coroutine_desc * current_coroutine;
|
---|
65 | thread_desc * current_thread;
|
---|
66 | pthread_t kernel_thread;
|
---|
67 |
|
---|
68 | signal_once terminated;
|
---|
69 | volatile bool is_terminated;
|
---|
70 |
|
---|
71 | struct FinishAction finish;
|
---|
72 | };
|
---|
73 |
|
---|
74 | void ?{}(processor * this);
|
---|
75 | void ?{}(processor * this, cluster * cltr);
|
---|
76 | void ^?{}(processor * this);
|
---|
77 |
|
---|
78 | #endif //KERNEL_H
|
---|
79 |
|
---|
80 | // Local Variables: //
|
---|
81 | // mode: c //
|
---|
82 | // tab-width: 4 //
|
---|
83 | // End: //
|
---|