Ignore:
Timestamp:
Feb 27, 2020, 4:04:25 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
a037f85
Parents:
41efd33 (diff), 930b504 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

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

    r41efd33 r04e6f93  
    4747        extern "Cforall" {
    4848                extern __attribute__((aligned(128))) thread_local struct KernelThreadData {
    49                         struct thread_desc    * volatile this_thread;
     49                        struct $thread    * volatile this_thread;
    5050                        struct processor      * volatile this_processor;
    5151
     
    9292        };
    9393
    94         enum coroutine_state { Halted, Start, Inactive, Active, Primed };
    95 
    96         struct coroutine_desc {
    97                 // context that is switch during a CtxSwitch
     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
    9899                struct __stack_context_t context;
    99100
     
    108109
    109110                // first coroutine to resume this one
    110                 struct coroutine_desc * starter;
     111                struct $coroutine * starter;
    111112
    112113                // last coroutine to resume this one
    113                 struct coroutine_desc * last;
     114                struct $coroutine * last;
    114115
    115116                // If non-null stack must be unwound with this exception
     
    127128        };
    128129
    129         struct monitor_desc {
     130        struct $monitor {
    130131                // spinlock to protect internal data
    131132                struct __spinlock_t lock;
    132133
    133134                // current owner of the monitor
    134                 struct thread_desc * owner;
     135                struct $thread * owner;
    135136
    136137                // queue of threads that are blocked waiting for the monitor
    137                 __queue_t(struct thread_desc) entry_queue;
     138                __queue_t(struct $thread) entry_queue;
    138139
    139140                // stack of conditions to run next once we exit the monitor
     
    152153        struct __monitor_group_t {
    153154                // currently held monitors
    154                 __cfa_anonymous_object( __small_array_t(monitor_desc*) );
     155                __cfa_anonymous_object( __small_array_t($monitor*) );
    155156
    156157                // last function that acquired monitors
     
    158159        };
    159160
    160         struct thread_desc {
     161        struct $thread {
    161162                // Core threading fields
    162                 // context that is switch during a CtxSwitch
     163                // context that is switch during a __cfactx_switch
    163164                struct __stack_context_t context;
    164165
    165166                // current execution status for coroutine
    166                 enum coroutine_state state;
     167                volatile int state;
     168                enum __Preemption_Reason preempted;
    167169
    168170                //SKULLDUGGERY errno is not save in the thread data structure because returnToKernel appears to be the only function to require saving and restoring it
    169171
    170172                // coroutine body used to store context
    171                 struct coroutine_desc  self_cor;
     173                struct $coroutine  self_cor;
    172174
    173175                // current active context
    174                 struct coroutine_desc * curr_cor;
     176                struct $coroutine * curr_cor;
    175177
    176178                // monitor body used for mutual exclusion
    177                 struct monitor_desc    self_mon;
     179                struct $monitor    self_mon;
    178180
    179181                // pointer to monitor with sufficient lifetime for current monitors
    180                 struct monitor_desc *  self_mon_p;
     182                struct $monitor *  self_mon_p;
    181183
    182184                // pointer to the cluster on which the thread is running
     
    188190                // Link lists fields
    189191                // instrusive link field for threads
    190                 struct thread_desc * next;
     192                struct $thread * next;
    191193
    192194                struct {
    193                         struct thread_desc * next;
    194                         struct thread_desc * prev;
     195                        struct $thread * next;
     196                        struct $thread * prev;
    195197                } node;
    196198        };
     
    198200        #ifdef __cforall
    199201        extern "Cforall" {
    200                 static inline thread_desc *& get_next( thread_desc & this ) {
     202                static inline $thread *& get_next( $thread & this ) __attribute__((const)) {
    201203                        return this.next;
    202204                }
    203205
    204                 static inline [thread_desc *&, thread_desc *& ] __get( thread_desc & this ) {
     206                static inline [$thread *&, $thread *& ] __get( $thread & this ) __attribute__((const)) {
    205207                        return this.node.[next, prev];
    206208                }
     
    212214                }
    213215
    214                 static inline void ?{}(__monitor_group_t & this, struct monitor_desc ** data, __lock_size_t size, fptr_t func) {
     216                static inline void ?{}(__monitor_group_t & this, struct $monitor ** data, __lock_size_t size, fptr_t func) {
    215217                        (this.data){data};
    216218                        (this.size){size};
     
    218220                }
    219221
    220                 static inline bool ?==?( const __monitor_group_t & lhs, const __monitor_group_t & rhs ) {
     222                static inline bool ?==?( const __monitor_group_t & lhs, const __monitor_group_t & rhs ) __attribute__((const)) {
    221223                        if( (lhs.data != 0) != (rhs.data != 0) ) return false;
    222224                        if( lhs.size != rhs.size ) return false;
     
    252254
    253255        // assembler routines that performs the context switch
    254         extern void CtxInvokeStub( void );
    255         extern void CtxSwitch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("CtxSwitch");
     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");
    256258        // void CtxStore ( void * this ) asm ("CtxStore");
    257259        // void CtxRet   ( void * dst  ) asm ("CtxRet");
Note: See TracChangeset for help on using the changeset viewer.