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 | // threads --
|
---|
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( simple_lock * );
|
---|
31 | // void lock( simple_lock *, spinlock * );
|
---|
32 | // void unlock( simple_lock * );
|
---|
33 |
|
---|
34 | void lock( spinlock * );
|
---|
35 | void unlock( spinlock * );
|
---|
36 |
|
---|
37 | void wait( signal_once * );
|
---|
38 | void signal( signal_once * );
|
---|
39 |
|
---|
40 | //-----------------------------------------------------------------------------
|
---|
41 | // Cluster
|
---|
42 | struct cluster {
|
---|
43 | simple_thread_list ready_queue;
|
---|
44 | spinlock lock;
|
---|
45 | };
|
---|
46 |
|
---|
47 | void ?{}(cluster * this);
|
---|
48 | void ^?{}(cluster * this);
|
---|
49 |
|
---|
50 | //-----------------------------------------------------------------------------
|
---|
51 | // Processor
|
---|
52 | enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule };
|
---|
53 | struct FinishAction {
|
---|
54 | FinishOpCode action_code;
|
---|
55 | thread * thrd;
|
---|
56 | spinlock * lock;
|
---|
57 | };
|
---|
58 | static inline void ?{}(FinishAction * this) {
|
---|
59 | this->action_code = No_Action;
|
---|
60 | this->thrd = NULL;
|
---|
61 | this->lock = NULL;
|
---|
62 | }
|
---|
63 | static inline void ^?{}(FinishAction * this) {}
|
---|
64 |
|
---|
65 | struct processor {
|
---|
66 | struct processorCtx_t * runner;
|
---|
67 | cluster * cltr;
|
---|
68 | coroutine * current_coroutine;
|
---|
69 | thread * current_thread;
|
---|
70 | pthread_t kernel_thread;
|
---|
71 |
|
---|
72 | signal_once terminated;
|
---|
73 | volatile bool is_terminated;
|
---|
74 |
|
---|
75 | struct FinishAction finish;
|
---|
76 | };
|
---|
77 |
|
---|
78 | void ?{}(processor * this);
|
---|
79 | void ?{}(processor * this, cluster * cltr);
|
---|
80 | void ^?{}(processor * this);
|
---|
81 |
|
---|
82 | #endif //KERNEL_H
|
---|
83 |
|
---|
84 | // Local Variables: //
|
---|
85 | // mode: c //
|
---|
86 | // tab-width: 4 //
|
---|
87 | // End: //
|
---|