[8118303] | 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
|
---|
[75f3522] | 11 | // Created On : Tue Jan 17 12:27:26 2017
|
---|
[8118303] | 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 |
|
---|
[c84e80a] | 20 | #include <stdbool.h>
|
---|
[8118303] | 21 |
|
---|
[bd98b58] | 22 | #include "invoke.h"
|
---|
| 23 |
|
---|
[8def349] | 24 | extern "C" {
|
---|
| 25 | #include <pthread.h>
|
---|
| 26 | }
|
---|
| 27 |
|
---|
[db6f06a] | 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 |
|
---|
[bd98b58] | 40 | //-----------------------------------------------------------------------------
|
---|
| 41 | // Cluster
|
---|
| 42 | struct cluster {
|
---|
| 43 | simple_thread_list ready_queue;
|
---|
[db6f06a] | 44 | spinlock lock;
|
---|
[bd98b58] | 45 | };
|
---|
| 46 |
|
---|
| 47 | void ?{}(cluster * this);
|
---|
| 48 | void ^?{}(cluster * this);
|
---|
| 49 |
|
---|
| 50 | //-----------------------------------------------------------------------------
|
---|
| 51 | // Processor
|
---|
[db6f06a] | 52 | enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule };
|
---|
| 53 | struct FinishAction {
|
---|
| 54 | FinishOpCode action_code;
|
---|
| 55 | thread * thrd;
|
---|
| 56 | spinlock * lock;
|
---|
[8fcbb4c] | 57 | };
|
---|
[db6f06a] | 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) {}
|
---|
[8fcbb4c] | 64 |
|
---|
[c84e80a] | 65 | struct processor {
|
---|
[8fcbb4c] | 66 | struct processorCtx_t * runner;
|
---|
[bd98b58] | 67 | cluster * cltr;
|
---|
| 68 | coroutine * current_coroutine;
|
---|
[e15df4c] | 69 | thread * current_thread;
|
---|
[8def349] | 70 | pthread_t kernel_thread;
|
---|
[db6f06a] | 71 |
|
---|
| 72 | signal_once terminated;
|
---|
| 73 | volatile bool is_terminated;
|
---|
| 74 |
|
---|
| 75 | struct FinishAction finish;
|
---|
[c84e80a] | 76 | };
|
---|
| 77 |
|
---|
[8def349] | 78 | void ?{}(processor * this);
|
---|
[bd98b58] | 79 | void ?{}(processor * this, cluster * cltr);
|
---|
[c84e80a] | 80 | void ^?{}(processor * this);
|
---|
| 81 |
|
---|
[8118303] | 82 | #endif //KERNEL_H
|
---|
| 83 |
|
---|
| 84 | // Local Variables: //
|
---|
| 85 | // mode: c //
|
---|
| 86 | // tab-width: 4 //
|
---|
| 87 | // End: //
|
---|