source: libcfa/src/concurrency/kernel_private.hfa @ 3381ed7

arm-ehjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-expr
Last change on this file since 3381ed7 was 3381ed7, checked in by Thierry Delisle <tdelisle@…>, 22 months ago

Added park/unpark primitives thread and removed BlockInternal?.
Converted monitors to use park unpark.
Intrusive Queue now mark next field when thread is inside queue.
Added several asserts to kernel and monitor.
Added a few tests for park and unpark.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// kernel_private.hfa --
8//
9// Author           : Thierry Delisle
10// Created On       : Mon Feb 13 12:27:26 2017
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Sat Nov 30 19:25:02 2019
13// Update Count     : 8
14//
15
16#pragma once
17
18#include "kernel.hfa"
19#include "thread.hfa"
20
21#include "alarm.hfa"
22
23
24//-----------------------------------------------------------------------------
25// Scheduler
26
27extern "C" {
28        void disable_interrupts() OPTIONAL_THREAD;
29        void enable_interrupts_noPoll();
30        void enable_interrupts( __cfaabi_dbg_ctx_param );
31}
32
33void ScheduleThread( thread_desc * ) __attribute__((nonnull (1)));
34
35//Block current thread and release/wake-up the following resources
36void LeaveThread();
37
38bool force_yield( enum __Preemption_Reason );
39
40//-----------------------------------------------------------------------------
41// Processor
42void main(processorCtx_t *);
43
44void * create_pthread( pthread_t *, void * (*)(void *), void * );
45
46static inline void wake_fast(processor * this) {
47        __cfaabi_dbg_print_safe("Kernel : Waking up processor %p\n", this);
48        post( this->idleLock );
49}
50
51static inline void wake(processor * this) {
52        disable_interrupts();
53        wake_fast(this);
54        enable_interrupts( __cfaabi_dbg_ctx );
55}
56
57struct event_kernel_t {
58        alarm_list_t alarms;
59        __spinlock_t lock;
60};
61
62extern event_kernel_t * event_kernel;
63
64struct __cfa_kernel_preemption_state_t {
65        bool enabled;
66        bool in_progress;
67        unsigned short disable_count;
68};
69
70extern volatile thread_local __cfa_kernel_preemption_state_t preemption_state __attribute__ ((tls_model ( "initial-exec" )));
71
72//-----------------------------------------------------------------------------
73// Threads
74extern "C" {
75      void CtxInvokeThread(void (*main)(void *), void * this);
76}
77
78extern void ThreadCtxSwitch(coroutine_desc * src, coroutine_desc * dst);
79
80__cfaabi_dbg_debug_do(
81        extern void __cfaabi_dbg_thread_register  ( thread_desc * thrd );
82        extern void __cfaabi_dbg_thread_unregister( thread_desc * thrd );
83)
84
85//-----------------------------------------------------------------------------
86// Utils
87#define KERNEL_STORAGE(T,X) static char storage_##X[sizeof(T)]
88
89static inline uint32_t tls_rand() {
90        kernelTLS.rand_seed ^= kernelTLS.rand_seed << 6;
91        kernelTLS.rand_seed ^= kernelTLS.rand_seed >> 21;
92        kernelTLS.rand_seed ^= kernelTLS.rand_seed << 7;
93        return kernelTLS.rand_seed;
94}
95
96
97void doregister( struct cluster & cltr );
98void unregister( struct cluster & cltr );
99
100void doregister( struct cluster * cltr, struct thread_desc & thrd );
101void unregister( struct cluster * cltr, struct thread_desc & thrd );
102
103void doregister( struct cluster * cltr, struct processor * proc );
104void unregister( struct cluster * cltr, struct processor * proc );
105
106// Local Variables: //
107// mode: c //
108// tab-width: 4 //
109// End: //
Note: See TracBrowser for help on using the repository browser.