[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 | //
|
---|
[75a17f1] | 8 | // kernel --
|
---|
[8118303] | 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
|
---|
[c81ebf9] | 30 | bool try_lock( spinlock * );
|
---|
[db6f06a] | 31 | void lock( spinlock * );
|
---|
| 32 | void unlock( spinlock * );
|
---|
| 33 |
|
---|
[9c31349] | 34 | struct signal_once {
|
---|
[5ea06d6] | 35 | volatile bool cond;
|
---|
[9c31349] | 36 | struct spinlock lock;
|
---|
[5ea06d6] | 37 | struct __thread_queue_t blocked;
|
---|
[9c31349] | 38 | };
|
---|
| 39 |
|
---|
| 40 | void ?{}(signal_once * this);
|
---|
| 41 | void ^?{}(signal_once * this);
|
---|
| 42 |
|
---|
[db6f06a] | 43 | void wait( signal_once * );
|
---|
| 44 | void signal( signal_once * );
|
---|
| 45 |
|
---|
[bd98b58] | 46 | //-----------------------------------------------------------------------------
|
---|
| 47 | // Cluster
|
---|
| 48 | struct cluster {
|
---|
[5ea06d6] | 49 | __thread_queue_t ready_queue;
|
---|
[db6f06a] | 50 | spinlock lock;
|
---|
[bd98b58] | 51 | };
|
---|
| 52 |
|
---|
| 53 | void ?{}(cluster * this);
|
---|
| 54 | void ^?{}(cluster * this);
|
---|
| 55 |
|
---|
| 56 | //-----------------------------------------------------------------------------
|
---|
| 57 | // Processor
|
---|
[0c78741] | 58 | enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule, Release_Multi, Release_Multi_Schedule };
|
---|
| 59 |
|
---|
| 60 | //TODO use union, many of these fields are mutually exclusive (i.e. MULTI vs NOMULTI)
|
---|
[db6f06a] | 61 | struct FinishAction {
|
---|
| 62 | FinishOpCode action_code;
|
---|
[348006f] | 63 | thread_desc * thrd;
|
---|
[db6f06a] | 64 | spinlock * lock;
|
---|
[0c78741] | 65 | spinlock ** locks;
|
---|
| 66 | unsigned short lock_count;
|
---|
| 67 | thread_desc ** thrds;
|
---|
| 68 | unsigned short thrd_count;
|
---|
[8fcbb4c] | 69 | };
|
---|
[db6f06a] | 70 | static inline void ?{}(FinishAction * this) {
|
---|
| 71 | this->action_code = No_Action;
|
---|
| 72 | this->thrd = NULL;
|
---|
| 73 | this->lock = NULL;
|
---|
| 74 | }
|
---|
| 75 | static inline void ^?{}(FinishAction * this) {}
|
---|
[8fcbb4c] | 76 |
|
---|
[c84e80a] | 77 | struct processor {
|
---|
[8fcbb4c] | 78 | struct processorCtx_t * runner;
|
---|
[bd98b58] | 79 | cluster * cltr;
|
---|
[c3acb841] | 80 | coroutine_desc * current_coroutine;
|
---|
[348006f] | 81 | thread_desc * current_thread;
|
---|
[8def349] | 82 | pthread_t kernel_thread;
|
---|
[db6f06a] | 83 |
|
---|
| 84 | signal_once terminated;
|
---|
| 85 | volatile bool is_terminated;
|
---|
| 86 |
|
---|
| 87 | struct FinishAction finish;
|
---|
[c81ebf9] | 88 |
|
---|
| 89 | struct alarm_node_t * preemption_alarm;
|
---|
| 90 | unsigned int preemption;
|
---|
| 91 |
|
---|
| 92 | unsigned short disable_preempt_count;
|
---|
| 93 |
|
---|
| 94 | bool pending_preemption;
|
---|
[c84e80a] | 95 | };
|
---|
| 96 |
|
---|
[8def349] | 97 | void ?{}(processor * this);
|
---|
[bd98b58] | 98 | void ?{}(processor * this, cluster * cltr);
|
---|
[c84e80a] | 99 | void ^?{}(processor * this);
|
---|
| 100 |
|
---|
[8118303] | 101 | #endif //KERNEL_H
|
---|
| 102 |
|
---|
| 103 | // Local Variables: //
|
---|
[fa21ac9] | 104 | // mode: CFA //
|
---|
| 105 | // tab-width: 6 //
|
---|
[8118303] | 106 | // End: //
|
---|