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