Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/invoke.h

    rac2b598 r3623f9d  
    1010// Created On       : Tue Jan 17 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec  5 16:26:03 2019
    13 // Update Count     : 44
     12// Last Modified On : Sat Jun 22 18:19:13 2019
     13// Update Count     : 40
    1414//
    1515
     
    4646        #ifdef __cforall
    4747        extern "Cforall" {
    48                 extern __attribute__((aligned(128))) thread_local struct KernelThreadData {
    49                         struct $thread    * volatile this_thread;
     48                extern thread_local struct KernelThreadData {
     49                        struct thread_desc    * volatile this_thread;
    5050                        struct processor      * volatile this_processor;
    5151
     
    5555                                volatile bool in_progress;
    5656                        } preemption_state;
    57 
    58                         uint32_t rand_seed;
    5957                } kernelTLS __attribute__ ((tls_model ( "initial-exec" )));
    6058        }
     
    9290        };
    9391
    94         enum coroutine_state { Halted, Start, Primed, Inactive, Active, Rerun };
    95         enum __Preemption_Reason { __NO_PREEMPTION, __ALARM_PREEMPTION, __POLL_PREEMPTION, __MANUAL_PREEMPTION };
    96 
    97         struct $coroutine {
    98                 // context that is switch during a __cfactx_switch
     92        enum coroutine_state { Halted, Start, Inactive, Active, Primed };
     93
     94        struct coroutine_desc {
     95                // context that is switch during a CtxSwitch
    9996                struct __stack_context_t context;
    10097
     
    109106
    110107                // first coroutine to resume this one
    111                 struct $coroutine * starter;
     108                struct coroutine_desc * starter;
    112109
    113110                // last coroutine to resume this one
    114                 struct $coroutine * last;
     111                struct coroutine_desc * last;
    115112
    116113                // If non-null stack must be unwound with this exception
     
    128125        };
    129126
    130         struct $monitor {
     127        struct monitor_desc {
    131128                // spinlock to protect internal data
    132129                struct __spinlock_t lock;
    133130
    134131                // current owner of the monitor
    135                 struct $thread * owner;
     132                struct thread_desc * owner;
    136133
    137134                // queue of threads that are blocked waiting for the monitor
    138                 __queue_t(struct $thread) entry_queue;
     135                __queue_t(struct thread_desc) entry_queue;
    139136
    140137                // stack of conditions to run next once we exit the monitor
     
    153150        struct __monitor_group_t {
    154151                // currently held monitors
    155                 __cfa_anonymous_object( __small_array_t($monitor*) );
     152                __cfa_anonymous_object( __small_array_t(monitor_desc*) );
    156153
    157154                // last function that acquired monitors
     
    159156        };
    160157
    161         struct $thread {
     158        struct thread_desc {
    162159                // Core threading fields
    163                 // context that is switch during a __cfactx_switch
     160                // context that is switch during a CtxSwitch
    164161                struct __stack_context_t context;
    165162
    166163                // current execution status for coroutine
    167                 volatile int state;
    168                 enum __Preemption_Reason preempted;
     164                enum coroutine_state state;
    169165
    170166                //SKULLDUGGERY errno is not save in the thread data structure because returnToKernel appears to be the only function to require saving and restoring it
    171167
    172168                // coroutine body used to store context
    173                 struct $coroutine  self_cor;
     169                struct coroutine_desc  self_cor;
    174170
    175171                // current active context
    176                 struct $coroutine * curr_cor;
     172                struct coroutine_desc * curr_cor;
    177173
    178174                // monitor body used for mutual exclusion
    179                 struct $monitor    self_mon;
     175                struct monitor_desc    self_mon;
    180176
    181177                // pointer to monitor with sufficient lifetime for current monitors
    182                 struct $monitor *  self_mon_p;
     178                struct monitor_desc *  self_mon_p;
    183179
    184180                // pointer to the cluster on which the thread is running
     
    190186                // Link lists fields
    191187                // instrusive link field for threads
    192                 struct $thread * next;
     188                struct thread_desc * next;
    193189
    194190                struct {
    195                         struct $thread * next;
    196                         struct $thread * prev;
     191                        struct thread_desc * next;
     192                        struct thread_desc * prev;
    197193                } node;
    198194        };
     
    200196        #ifdef __cforall
    201197        extern "Cforall" {
    202                 static inline $thread *& get_next( $thread & this ) __attribute__((const)) {
     198                static inline thread_desc *& get_next( thread_desc & this ) {
    203199                        return this.next;
    204200                }
    205201
    206                 static inline [$thread *&, $thread *& ] __get( $thread & this ) __attribute__((const)) {
     202                static inline [thread_desc *&, thread_desc *& ] __get( thread_desc & this ) {
    207203                        return this.node.[next, prev];
    208204                }
    209205
    210206                static inline void ?{}(__monitor_group_t & this) {
    211                         (this.data){0p};
     207                        (this.data){NULL};
    212208                        (this.size){0};
    213209                        (this.func){NULL};
    214210                }
    215211
    216                 static inline void ?{}(__monitor_group_t & this, struct $monitor ** data, __lock_size_t size, fptr_t func) {
     212                static inline void ?{}(__monitor_group_t & this, struct monitor_desc ** data, __lock_size_t size, fptr_t func) {
    217213                        (this.data){data};
    218214                        (this.size){size};
     
    220216                }
    221217
    222                 static inline bool ?==?( const __monitor_group_t & lhs, const __monitor_group_t & rhs ) __attribute__((const)) {
     218                static inline bool ?==?( const __monitor_group_t & lhs, const __monitor_group_t & rhs ) {
    223219                        if( (lhs.data != 0) != (rhs.data != 0) ) return false;
    224220                        if( lhs.size != rhs.size ) return false;
     
    254250
    255251        // assembler routines that performs the context switch
    256         extern void __cfactx_invoke_stub( void );
    257         extern void __cfactx_switch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("__cfactx_switch");
     252        extern void CtxInvokeStub( void );
     253        extern void CtxSwitch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("CtxSwitch");
    258254        // void CtxStore ( void * this ) asm ("CtxStore");
    259255        // void CtxRet   ( void * dst  ) asm ("CtxRet");
Note: See TracChangeset for help on using the changeset viewer.