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 | // kernel_private.h --
|
---|
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 "libhdr.h"
|
---|
21 |
|
---|
22 | #include "kernel"
|
---|
23 | #include "thread"
|
---|
24 |
|
---|
25 | #include "alarm.h"
|
---|
26 |
|
---|
27 |
|
---|
28 | //-----------------------------------------------------------------------------
|
---|
29 | // Scheduler
|
---|
30 |
|
---|
31 | extern "C" {
|
---|
32 | void disable_interrupts();
|
---|
33 | void enable_interrupts_noRF();
|
---|
34 | void enable_interrupts( DEBUG_CTX_PARAM );
|
---|
35 | }
|
---|
36 |
|
---|
37 | void ScheduleThread( thread_desc * );
|
---|
38 | static inline void WakeThread( thread_desc * thrd ) {
|
---|
39 | if( !thrd ) return;
|
---|
40 |
|
---|
41 | disable_interrupts();
|
---|
42 | ScheduleThread( thrd );
|
---|
43 | enable_interrupts( DEBUG_CTX );
|
---|
44 | }
|
---|
45 | thread_desc * nextThread(cluster * this);
|
---|
46 |
|
---|
47 | void BlockInternal(void);
|
---|
48 | void BlockInternal(spinlock * lock);
|
---|
49 | void BlockInternal(thread_desc * thrd);
|
---|
50 | void BlockInternal(spinlock * lock, thread_desc * thrd);
|
---|
51 | void BlockInternal(spinlock ** locks, unsigned short count);
|
---|
52 | void BlockInternal(spinlock ** locks, unsigned short count, thread_desc ** thrds, unsigned short thrd_count);
|
---|
53 |
|
---|
54 | //-----------------------------------------------------------------------------
|
---|
55 | // Processor
|
---|
56 | coroutine processorCtx_t {
|
---|
57 | processor * proc;
|
---|
58 | };
|
---|
59 |
|
---|
60 | void main(processorCtx_t *);
|
---|
61 | void start(processor * this);
|
---|
62 | void runThread(processor * this, thread_desc * dst);
|
---|
63 | void finishRunning(processor * this);
|
---|
64 | void spin(processor * this, unsigned int * spin_count);
|
---|
65 |
|
---|
66 | struct system_proc_t {
|
---|
67 | processor proc;
|
---|
68 |
|
---|
69 | alarm_list_t alarms;
|
---|
70 | spinlock alarm_lock;
|
---|
71 |
|
---|
72 | bool pending_alarm;
|
---|
73 | };
|
---|
74 |
|
---|
75 | extern cluster * systemCluster;
|
---|
76 | extern system_proc_t * systemProcessor;
|
---|
77 | extern volatile thread_local processor * this_processor;
|
---|
78 | extern volatile thread_local coroutine_desc * this_coroutine;
|
---|
79 | extern volatile thread_local thread_desc * this_thread;
|
---|
80 | extern volatile thread_local unsigned short disable_preempt_count;
|
---|
81 |
|
---|
82 | //-----------------------------------------------------------------------------
|
---|
83 | // Threads
|
---|
84 | extern "C" {
|
---|
85 | forall(dtype T | is_thread(T))
|
---|
86 | void CtxInvokeThread(T * this);
|
---|
87 | }
|
---|
88 |
|
---|
89 | extern void ThreadCtxSwitch(coroutine_desc * src, coroutine_desc * dst);
|
---|
90 |
|
---|
91 | #endif //KERNEL_PRIVATE_H
|
---|
92 |
|
---|
93 | // Local Variables: //
|
---|
94 | // mode: c //
|
---|
95 | // tab-width: 4 //
|
---|
96 | // End: //
|
---|