| [75f3522] | 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_private.h --
|
|---|
| [75f3522] | 9 | //
|
|---|
| 10 | // Author : Thierry Delisle
|
|---|
| 11 | // Created On : Mon Feb 13 12:27:26 2017
|
|---|
| 12 | // Last Modified By : Thierry Delisle
|
|---|
| 13 | // Last Modified On : --
|
|---|
| 14 | // Update Count : 0
|
|---|
| 15 | //
|
|---|
| 16 |
|
|---|
| 17 | #ifndef KERNEL_PRIVATE_H
|
|---|
| 18 | #define KERNEL_PRIVATE_H
|
|---|
| 19 |
|
|---|
| 20 | #include "kernel"
|
|---|
| [75a17f1] | 21 | #include "thread"
|
|---|
| [75f3522] | 22 |
|
|---|
| [fa21ac9] | 23 | #include "alarm.h"
|
|---|
| 24 |
|
|---|
| [4aa2fb2] | 25 | #include "libhdr.h"
|
|---|
| 26 |
|
|---|
| [75f3522] | 27 | //-----------------------------------------------------------------------------
|
|---|
| 28 | // Scheduler
|
|---|
| [1c273d0] | 29 |
|
|---|
| 30 | extern "C" {
|
|---|
| 31 | void disable_interrupts();
|
|---|
| 32 | void enable_interrupts_noRF();
|
|---|
| 33 | void enable_interrupts( const char * );
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| [348006f] | 36 | void ScheduleThread( thread_desc * );
|
|---|
| [1c273d0] | 37 | static inline void WakeThread( thread_desc * thrd ) {
|
|---|
| 38 | if( !thrd ) return;
|
|---|
| 39 |
|
|---|
| 40 | disable_interrupts();
|
|---|
| 41 | ScheduleThread( thrd );
|
|---|
| 42 | enable_interrupts( __PRETTY_FUNCTION__ );
|
|---|
| 43 | }
|
|---|
| [348006f] | 44 | thread_desc * nextThread(cluster * this);
|
|---|
| [75f3522] | 45 |
|
|---|
| [82ff5845] | 46 | void BlockInternal(void);
|
|---|
| 47 | void BlockInternal(spinlock * lock);
|
|---|
| 48 | void BlockInternal(thread_desc * thrd);
|
|---|
| 49 | void BlockInternal(spinlock * lock, thread_desc * thrd);
|
|---|
| 50 | void BlockInternal(spinlock ** locks, unsigned short count);
|
|---|
| 51 | void BlockInternal(spinlock ** locks, unsigned short count, thread_desc ** thrds, unsigned short thrd_count);
|
|---|
| [db6f06a] | 52 |
|
|---|
| [75f3522] | 53 | //-----------------------------------------------------------------------------
|
|---|
| 54 | // Processor
|
|---|
| [fa21ac9] | 55 | coroutine processorCtx_t {
|
|---|
| [75f3522] | 56 | processor * proc;
|
|---|
| 57 | };
|
|---|
| 58 |
|
|---|
| 59 | void main(processorCtx_t *);
|
|---|
| [db6f06a] | 60 | void start(processor * this);
|
|---|
| [348006f] | 61 | void runThread(processor * this, thread_desc * dst);
|
|---|
| [db6f06a] | 62 | void finishRunning(processor * this);
|
|---|
| [75f3522] | 63 | void spin(processor * this, unsigned int * spin_count);
|
|---|
| 64 |
|
|---|
| [fa21ac9] | 65 | struct system_proc_t {
|
|---|
| 66 | processor proc;
|
|---|
| 67 |
|
|---|
| 68 | alarm_list_t alarms;
|
|---|
| 69 | spinlock alarm_lock;
|
|---|
| [c81ebf9] | 70 |
|
|---|
| 71 | bool pending_alarm;
|
|---|
| [fa21ac9] | 72 | };
|
|---|
| 73 |
|
|---|
| 74 | extern cluster * systemCluster;
|
|---|
| 75 | extern system_proc_t * systemProcessor;
|
|---|
| [4e6fb8e] | 76 | extern volatile thread_local processor * this_processor;
|
|---|
| [1c273d0] | 77 | extern volatile thread_local coroutine_desc * this_coroutine;
|
|---|
| 78 | extern volatile thread_local thread_desc * this_thread;
|
|---|
| [4e6fb8e] | 79 | extern volatile thread_local unsigned short disable_preempt_count;
|
|---|
| [c81ebf9] | 80 |
|
|---|
| [75f3522] | 81 | //-----------------------------------------------------------------------------
|
|---|
| 82 | // Threads
|
|---|
| 83 | extern "C" {
|
|---|
| 84 | forall(dtype T | is_thread(T))
|
|---|
| 85 | void CtxInvokeThread(T * this);
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| [c3acb841] | 88 | extern void ThreadCtxSwitch(coroutine_desc * src, coroutine_desc * dst);
|
|---|
| [75f3522] | 89 |
|
|---|
| 90 | #endif //KERNEL_PRIVATE_H
|
|---|
| 91 |
|
|---|
| 92 | // Local Variables: //
|
|---|
| 93 | // mode: c //
|
|---|
| 94 | // tab-width: 4 //
|
|---|
| [4aa2fb2] | 95 | // End: //
|
|---|