source: src/libcfa/concurrency/kernel_private.h @ 1c273d0

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 1c273d0 was 1c273d0, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

preemption works for threads

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