Changeset ac2b598


Ignore:
Timestamp:
Feb 24, 2020, 2:21:03 PM (20 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
959f6ad
Parents:
0f2c555
Message:

Changed descriptors for concurrency to use $ prefix instead of trailing _desc

Files:
19 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/alarm.cfa

    r0f2c555 rac2b598  
    4747//=============================================================================================
    4848
    49 void ?{}( alarm_node_t & this, thread_desc * thrd, Time alarm, Duration period ) with( this ) {
     49void ?{}( alarm_node_t & this, $thread * thrd, Time alarm, Duration period ) with( this ) {
    5050        this.thrd = thrd;
    5151        this.alarm = alarm;
  • libcfa/src/concurrency/alarm.hfa

    r0f2c555 rac2b598  
    2323#include "time.hfa"
    2424
    25 struct thread_desc;
     25struct $thread;
    2626struct processor;
    2727
     
    4343
    4444        union {
    45                 thread_desc * thrd;     // thrd who created event
     45                $thread * thrd; // thrd who created event
    4646                processor * proc;               // proc who created event
    4747        };
     
    5353typedef alarm_node_t ** __alarm_it_t;
    5454
    55 void ?{}( alarm_node_t & this, thread_desc * thrd, Time alarm, Duration period );
     55void ?{}( alarm_node_t & this, $thread * thrd, Time alarm, Duration period );
    5656void ?{}( alarm_node_t & this, processor   * proc, Time alarm, Duration period );
    5757void ^?{}( alarm_node_t & this );
  • libcfa/src/concurrency/coroutine.cfa

    r0f2c555 rac2b598  
    3737
    3838extern "C" {
    39         void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct coroutine_desc *) __attribute__ ((__noreturn__));
     39        void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct $coroutine *) __attribute__ ((__noreturn__));
    4040        static void _CtxCoroutine_UnwindCleanup(_Unwind_Reason_Code, struct _Unwind_Exception *) __attribute__ ((__noreturn__));
    4141        static void _CtxCoroutine_UnwindCleanup(_Unwind_Reason_Code, struct _Unwind_Exception *) {
     
    8989}
    9090
    91 void ?{}( coroutine_desc & this, const char name[], void * storage, size_t storageSize ) with( this ) {
     91void ?{}( $coroutine & this, const char name[], void * storage, size_t storageSize ) with( this ) {
    9292        (this.context){0p, 0p};
    9393        (this.stack){storage, storageSize};
     
    9999}
    100100
    101 void ^?{}(coroutine_desc& this) {
     101void ^?{}($coroutine& this) {
    102102        if(this.state != Halted && this.state != Start && this.state != Primed) {
    103                 coroutine_desc * src = TL_GET( this_thread )->curr_cor;
    104                 coroutine_desc * dst = &this;
     103                $coroutine * src = TL_GET( this_thread )->curr_cor;
     104                $coroutine * dst = &this;
    105105
    106106                struct _Unwind_Exception storage;
     
    115115                }
    116116
    117                 CoroutineCtxSwitch( src, dst );
     117                $ctx_switch( src, dst );
    118118        }
    119119}
     
    123123forall(dtype T | is_coroutine(T))
    124124void prime(T& cor) {
    125         coroutine_desc* this = get_coroutine(cor);
     125        $coroutine* this = get_coroutine(cor);
    126126        assert(this->state == Start);
    127127
     
    187187// is not inline (We can't inline Cforall in C)
    188188extern "C" {
    189         void __cfactx_cor_leave( struct coroutine_desc * src ) {
    190                 coroutine_desc * starter = src->cancellation != 0 ? src->last : src->starter;
     189        void __cfactx_cor_leave( struct $coroutine * src ) {
     190                $coroutine * starter = src->cancellation != 0 ? src->last : src->starter;
    191191
    192192                src->state = Halted;
     
    201201                        src->name, src, starter->name, starter );
    202202
    203                 CoroutineCtxSwitch( src, starter );
    204         }
    205 
    206         struct coroutine_desc * __cfactx_cor_finish(void) {
    207                 struct coroutine_desc * cor = kernelTLS.this_thread->curr_cor;
     203                $ctx_switch( src, starter );
     204        }
     205
     206        struct $coroutine * __cfactx_cor_finish(void) {
     207                struct $coroutine * cor = kernelTLS.this_thread->curr_cor;
    208208
    209209                if(cor->state == Primed) {
  • libcfa/src/concurrency/coroutine.hfa

    r0f2c555 rac2b598  
    2525trait is_coroutine(dtype T) {
    2626      void main(T & this);
    27       coroutine_desc * get_coroutine(T & this);
     27      $coroutine * get_coroutine(T & this);
    2828};
    2929
    30 #define DECL_COROUTINE(X) static inline coroutine_desc* get_coroutine(X& this) { return &this.__cor; } void main(X& this)
     30#define DECL_COROUTINE(X) static inline $coroutine* get_coroutine(X& this) { return &this.__cor; } void main(X& this)
    3131
    3232//-----------------------------------------------------------------------------
     
    3535// void ^?{}( coStack_t & this );
    3636
    37 void ?{}( coroutine_desc & this, const char name[], void * storage, size_t storageSize );
    38 void ^?{}( coroutine_desc & this );
     37void  ?{}( $coroutine & this, const char name[], void * storage, size_t storageSize );
     38void ^?{}( $coroutine & this );
    3939
    40 static inline void ?{}( coroutine_desc & this)                                       { this{ "Anonymous Coroutine", 0p, 0 }; }
    41 static inline void ?{}( coroutine_desc & this, size_t stackSize)                     { this{ "Anonymous Coroutine", 0p, stackSize }; }
    42 static inline void ?{}( coroutine_desc & this, void * storage, size_t storageSize )  { this{ "Anonymous Coroutine", storage, storageSize }; }
    43 static inline void ?{}( coroutine_desc & this, const char name[])                    { this{ name, 0p, 0 }; }
    44 static inline void ?{}( coroutine_desc & this, const char name[], size_t stackSize ) { this{ name, 0p, stackSize }; }
     40static inline void ?{}( $coroutine & this)                                       { this{ "Anonymous Coroutine", 0p, 0 }; }
     41static inline void ?{}( $coroutine & this, size_t stackSize)                     { this{ "Anonymous Coroutine", 0p, stackSize }; }
     42static inline void ?{}( $coroutine & this, void * storage, size_t storageSize )  { this{ "Anonymous Coroutine", storage, storageSize }; }
     43static inline void ?{}( $coroutine & this, const char name[])                    { this{ name, 0p, 0 }; }
     44static inline void ?{}( $coroutine & this, const char name[], size_t stackSize ) { this{ name, 0p, stackSize }; }
    4545
    4646//-----------------------------------------------------------------------------
     
    5454void prime(T & cor);
    5555
    56 static inline struct coroutine_desc * active_coroutine() { return TL_GET( this_thread )->curr_cor; }
     56static inline struct $coroutine * active_coroutine() { return TL_GET( this_thread )->curr_cor; }
    5757
    5858//-----------------------------------------------------------------------------
     
    6464
    6565        forall(dtype T)
    66         void __cfactx_start(void (*main)(T &), struct coroutine_desc * cor, T & this, void (*invoke)(void (*main)(void *), void *));
     66        void __cfactx_start(void (*main)(T &), struct $coroutine * cor, T & this, void (*invoke)(void (*main)(void *), void *));
    6767
    68         extern void __cfactx_coroutine_unwind(struct _Unwind_Exception * storage, struct coroutine_desc *) __attribute__ ((__noreturn__));
     68        extern void __cfactx_coroutine_unwind(struct _Unwind_Exception * storage, struct $coroutine *) __attribute__ ((__noreturn__));
    6969
    7070        extern void __cfactx_switch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("__cfactx_switch");
     
    7373// Private wrappers for context switch and stack creation
    7474// Wrapper for co
    75 static inline void CoroutineCtxSwitch( coroutine_desc * src, coroutine_desc * dst ) __attribute__((nonnull (1, 2))) {
     75static inline void $ctx_switch( $coroutine * src, $coroutine * dst ) __attribute__((nonnull (1, 2))) {
    7676        // set state of current coroutine to inactive
    7777        src->state = src->state == Halted ? Halted : Inactive;
     
    102102        // will also migrate which means this value will
    103103        // stay in syn with the TLS
    104         coroutine_desc * src = TL_GET( this_thread )->curr_cor;
     104        $coroutine * src = TL_GET( this_thread )->curr_cor;
    105105
    106106        assertf( src->last != 0,
     
    113113                src->name, src, src->last->name, src->last );
    114114
    115         CoroutineCtxSwitch( src, src->last );
     115        $ctx_switch( src, src->last );
    116116}
    117117
     
    124124        // will also migrate which means this value will
    125125        // stay in syn with the TLS
    126         coroutine_desc * src = TL_GET( this_thread )->curr_cor;
    127         coroutine_desc * dst = get_coroutine(cor);
     126        $coroutine * src = TL_GET( this_thread )->curr_cor;
     127        $coroutine * dst = get_coroutine(cor);
    128128
    129129        if( unlikely(dst->context.SP == 0p) ) {
     
    147147
    148148        // always done for performance testing
    149         CoroutineCtxSwitch( src, dst );
     149        $ctx_switch( src, dst );
    150150
    151151        return cor;
    152152}
    153153
    154 static inline void resume( coroutine_desc * dst ) __attribute__((nonnull (1))) {
     154static inline void resume( $coroutine * dst ) __attribute__((nonnull (1))) {
    155155        // optimization : read TLS once and reuse it
    156156        // Safety note: this is preemption safe since if
     
    158158        // will also migrate which means this value will
    159159        // stay in syn with the TLS
    160         coroutine_desc * src = TL_GET( this_thread )->curr_cor;
     160        $coroutine * src = TL_GET( this_thread )->curr_cor;
    161161
    162162        // not resuming self ?
     
    172172
    173173        // always done for performance testing
    174         CoroutineCtxSwitch( src, dst );
     174        $ctx_switch( src, dst );
    175175}
    176176
  • libcfa/src/concurrency/invoke.c

    r0f2c555 rac2b598  
    2929// Called from the kernel when starting a coroutine or task so must switch back to user mode.
    3030
    31 extern struct coroutine_desc * __cfactx_cor_finish(void);
    32 extern void __cfactx_cor_leave ( struct coroutine_desc * );
     31extern struct $coroutine * __cfactx_cor_finish(void);
     32extern void __cfactx_cor_leave ( struct $coroutine * );
    3333extern void __cfactx_thrd_leave();
    3434
     
    4141) {
    4242        // Finish setting up the coroutine by setting its state
    43         struct coroutine_desc * cor = __cfactx_cor_finish();
     43        struct $coroutine * cor = __cfactx_cor_finish();
    4444
    4545        // Call the main of the coroutine
     
    7070}
    7171
    72 void __cfactx_coroutine_unwind(struct _Unwind_Exception * storage, struct coroutine_desc * cor) __attribute__ ((__noreturn__));
    73 void __cfactx_coroutine_unwind(struct _Unwind_Exception * storage, struct coroutine_desc * cor) {
     72void __cfactx_coroutine_unwind(struct _Unwind_Exception * storage, struct $coroutine * cor) __attribute__ ((__noreturn__));
     73void __cfactx_coroutine_unwind(struct _Unwind_Exception * storage, struct $coroutine * cor) {
    7474        _Unwind_Reason_Code ret = _Unwind_ForcedUnwind( storage, __cfactx_coroutine_unwindstop, cor );
    7575        printf("UNWIND ERROR %d after force unwind\n", ret);
     
    100100void __cfactx_start(
    101101        void (*main)(void *),
    102         struct coroutine_desc * cor,
     102        struct $coroutine * cor,
    103103        void *this,
    104104        void (*invoke)(void *)
  • libcfa/src/concurrency/invoke.h

    r0f2c555 rac2b598  
    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
     
    9595        enum __Preemption_Reason { __NO_PREEMPTION, __ALARM_PREEMPTION, __POLL_PREEMPTION, __MANUAL_PREEMPTION };
    9696
    97         struct coroutine_desc {
     97        struct $coroutine {
    9898                // context that is switch during a __cfactx_switch
    9999                struct __stack_context_t context;
     
    109109
    110110                // first coroutine to resume this one
    111                 struct coroutine_desc * starter;
     111                struct $coroutine * starter;
    112112
    113113                // last coroutine to resume this one
    114                 struct coroutine_desc * last;
     114                struct $coroutine * last;
    115115
    116116                // If non-null stack must be unwound with this exception
     
    128128        };
    129129
    130         struct monitor_desc {
     130        struct $monitor {
    131131                // spinlock to protect internal data
    132132                struct __spinlock_t lock;
    133133
    134134                // current owner of the monitor
    135                 struct thread_desc * owner;
     135                struct $thread * owner;
    136136
    137137                // queue of threads that are blocked waiting for the monitor
    138                 __queue_t(struct thread_desc) entry_queue;
     138                __queue_t(struct $thread) entry_queue;
    139139
    140140                // stack of conditions to run next once we exit the monitor
     
    153153        struct __monitor_group_t {
    154154                // currently held monitors
    155                 __cfa_anonymous_object( __small_array_t(monitor_desc*) );
     155                __cfa_anonymous_object( __small_array_t($monitor*) );
    156156
    157157                // last function that acquired monitors
     
    159159        };
    160160
    161         struct thread_desc {
     161        struct $thread {
    162162                // Core threading fields
    163163                // context that is switch during a __cfactx_switch
     
    171171
    172172                // coroutine body used to store context
    173                 struct coroutine_desc  self_cor;
     173                struct $coroutine  self_cor;
    174174
    175175                // current active context
    176                 struct coroutine_desc * curr_cor;
     176                struct $coroutine * curr_cor;
    177177
    178178                // monitor body used for mutual exclusion
    179                 struct monitor_desc    self_mon;
     179                struct $monitor    self_mon;
    180180
    181181                // pointer to monitor with sufficient lifetime for current monitors
    182                 struct monitor_desc *  self_mon_p;
     182                struct $monitor *  self_mon_p;
    183183
    184184                // pointer to the cluster on which the thread is running
     
    190190                // Link lists fields
    191191                // instrusive link field for threads
    192                 struct thread_desc * next;
     192                struct $thread * next;
    193193
    194194                struct {
    195                         struct thread_desc * next;
    196                         struct thread_desc * prev;
     195                        struct $thread * next;
     196                        struct $thread * prev;
    197197                } node;
    198198        };
     
    200200        #ifdef __cforall
    201201        extern "Cforall" {
    202                 static inline thread_desc *& get_next( thread_desc & this ) __attribute__((const)) {
     202                static inline $thread *& get_next( $thread & this ) __attribute__((const)) {
    203203                        return this.next;
    204204                }
    205205
    206                 static inline [thread_desc *&, thread_desc *& ] __get( thread_desc & this ) __attribute__((const)) {
     206                static inline [$thread *&, $thread *& ] __get( $thread & this ) __attribute__((const)) {
    207207                        return this.node.[next, prev];
    208208                }
     
    214214                }
    215215
    216                 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) {
    217217                        (this.data){data};
    218218                        (this.size){size};
  • libcfa/src/concurrency/kernel.cfa

    r0f2c555 rac2b598  
    117117KERNEL_STORAGE(cluster,         mainCluster);
    118118KERNEL_STORAGE(processor,       mainProcessor);
    119 KERNEL_STORAGE(thread_desc,     mainThread);
     119KERNEL_STORAGE($thread, mainThread);
    120120KERNEL_STORAGE(__stack_t,       mainThreadCtx);
    121121
    122122cluster     * mainCluster;
    123123processor   * mainProcessor;
    124 thread_desc * mainThread;
     124$thread * mainThread;
    125125
    126126extern "C" {
     
    164164// Main thread construction
    165165
    166 void ?{}( coroutine_desc & this, current_stack_info_t * info) with( this ) {
     166void ?{}( $coroutine & this, current_stack_info_t * info) with( this ) {
    167167        stack.storage = info->storage;
    168168        with(*stack.storage) {
     
    179179}
    180180
    181 void ?{}( thread_desc & this, current_stack_info_t * info) with( this ) {
     181void ?{}( $thread & this, current_stack_info_t * info) with( this ) {
    182182        state = Start;
    183183        self_cor{ info };
     
    264264// Kernel Scheduling logic
    265265//=============================================================================================
    266 static thread_desc * __next_thread(cluster * this);
    267 static void __run_thread(processor * this, thread_desc * dst);
     266static $thread * __next_thread(cluster * this);
     267static void __run_thread(processor * this, $thread * dst);
    268268static void __halt(processor * this);
    269269
     
    287287                __cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
    288288
    289                 thread_desc * readyThread = 0p;
     289                $thread * readyThread = 0p;
    290290                for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ ) {
    291291                        readyThread = __next_thread( this->cltr );
     
    323323// runThread runs a thread by context switching
    324324// from the processor coroutine to the target thread
    325 static void __run_thread(processor * this, thread_desc * thrd_dst) {
    326         coroutine_desc * proc_cor = get_coroutine(this->runner);
     325static void __run_thread(processor * this, $thread * thrd_dst) {
     326        $coroutine * proc_cor = get_coroutine(this->runner);
    327327
    328328        // Update global state
     
    400400void returnToKernel() {
    401401        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    402         coroutine_desc * proc_cor = get_coroutine(kernelTLS.this_processor->runner);
    403         thread_desc * thrd_src = kernelTLS.this_thread;
     402        $coroutine * proc_cor = get_coroutine(kernelTLS.this_processor->runner);
     403        $thread * thrd_src = kernelTLS.this_thread;
    404404
    405405        // Run the thread on this processor
     
    495495// KERNEL_ONLY
    496496static void __kernel_first_resume( processor * this ) {
    497         thread_desc * src = mainThread;
    498         coroutine_desc * dst = get_coroutine(this->runner);
     497        $thread * src = mainThread;
     498        $coroutine * dst = get_coroutine(this->runner);
    499499
    500500        verify( ! kernelTLS.preemption_state.enabled );
     
    527527// KERNEL_ONLY
    528528static void __kernel_last_resume( processor * this ) {
    529         coroutine_desc * src = &mainThread->self_cor;
    530         coroutine_desc * dst = get_coroutine(this->runner);
     529        $coroutine * src = &mainThread->self_cor;
     530        $coroutine * dst = get_coroutine(this->runner);
    531531
    532532        verify( ! kernelTLS.preemption_state.enabled );
     
    541541// Scheduler routines
    542542// KERNEL ONLY
    543 void __schedule_thread( thread_desc * thrd ) with( *thrd->curr_cluster ) {
     543void __schedule_thread( $thread * thrd ) with( *thrd->curr_cluster ) {
    544544        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    545545        /* paranoid */ #if defined( __CFA_WITH_VERIFY__ )
     
    571571
    572572// KERNEL ONLY
    573 static thread_desc * __next_thread(cluster * this) with( *this ) {
     573static $thread * __next_thread(cluster * this) with( *this ) {
    574574        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    575575
    576576        lock( ready_queue_lock __cfaabi_dbg_ctx2 );
    577         thread_desc * head = pop_head( ready_queue );
     577        $thread * head = pop_head( ready_queue );
    578578        unlock( ready_queue_lock );
    579579
     
    582582}
    583583
    584 void unpark( thread_desc * thrd ) {
     584void unpark( $thread * thrd ) {
    585585        if( !thrd ) return;
    586586
     
    639639        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    640640
    641         thread_desc * thrd = kernelTLS.this_thread;
     641        $thread * thrd = kernelTLS.this_thread;
    642642        /* paranoid */ verify(thrd->state == Active || thrd->state == Rerun);
    643643
     
    683683        // SKULLDUGGERY: the mainThread steals the process main thread
    684684        // which will then be scheduled by the mainProcessor normally
    685         mainThread = (thread_desc *)&storage_mainThread;
     685        mainThread = ($thread *)&storage_mainThread;
    686686        current_stack_info_t info;
    687687        info.storage = (__stack_t*)&storage_mainThreadCtx;
     
    835835
    836836void kernel_abort_msg( void * kernel_data, char * abort_text, int abort_text_size ) {
    837         thread_desc * thrd = kernel_data;
     837        $thread * thrd = kernel_data;
    838838
    839839        if(thrd) {
     
    900900
    901901void V(semaphore & this) with( this ) {
    902         thread_desc * thrd = 0p;
     902        $thread * thrd = 0p;
    903903        lock( lock __cfaabi_dbg_ctx2 );
    904904        count += 1;
     
    928928}
    929929
    930 void doregister( cluster * cltr, thread_desc & thrd ) {
     930void doregister( cluster * cltr, $thread & thrd ) {
    931931        lock      (cltr->thread_list_lock __cfaabi_dbg_ctx2);
    932932        cltr->nthreads += 1;
     
    935935}
    936936
    937 void unregister( cluster * cltr, thread_desc & thrd ) {
     937void unregister( cluster * cltr, $thread & thrd ) {
    938938        lock  (cltr->thread_list_lock __cfaabi_dbg_ctx2);
    939939        remove(cltr->threads, thrd );
  • libcfa/src/concurrency/kernel.hfa

    r0f2c555 rac2b598  
    3232        __spinlock_t lock;
    3333        int count;
    34         __queue_t(thread_desc) waiting;
     34        __queue_t($thread) waiting;
    3535};
    3636
     
    6767        // RunThread data
    6868        // Action to do after a thread is ran
    69         thread_desc * destroyer;
     69        $thread * destroyer;
    7070
    7171        // Preemption data
     
    117117
    118118        // Ready queue for threads
    119         __queue_t(thread_desc) ready_queue;
     119        __queue_t($thread) ready_queue;
    120120
    121121        // Name of the cluster
     
    133133        // List of threads
    134134        __spinlock_t thread_list_lock;
    135         __dllist_t(struct thread_desc) threads;
     135        __dllist_t(struct $thread) threads;
    136136        unsigned int nthreads;
    137137
  • libcfa/src/concurrency/kernel_private.hfa

    r0f2c555 rac2b598  
    3131}
    3232
    33 void __schedule_thread( thread_desc * ) __attribute__((nonnull (1)));
     33void __schedule_thread( $thread * ) __attribute__((nonnull (1)));
    3434
    3535//Block current thread and release/wake-up the following resources
     
    7474}
    7575
    76 extern void ThreadCtxSwitch(coroutine_desc * src, coroutine_desc * dst);
    77 
    7876__cfaabi_dbg_debug_do(
    79         extern void __cfaabi_dbg_thread_register  ( thread_desc * thrd );
    80         extern void __cfaabi_dbg_thread_unregister( thread_desc * thrd );
     77        extern void __cfaabi_dbg_thread_register  ( $thread * thrd );
     78        extern void __cfaabi_dbg_thread_unregister( $thread * thrd );
    8179)
    8280
     
    9694void unregister( struct cluster & cltr );
    9795
    98 void doregister( struct cluster * cltr, struct thread_desc & thrd );
    99 void unregister( struct cluster * cltr, struct thread_desc & thrd );
     96void doregister( struct cluster * cltr, struct $thread & thrd );
     97void unregister( struct cluster * cltr, struct $thread & thrd );
    10098
    10199void doregister( struct cluster * cltr, struct processor * proc );
  • libcfa/src/concurrency/monitor.cfa

    r0f2c555 rac2b598  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // monitor_desc.c --
     7// $monitor.c --
    88//
    99// Author           : Thierry Delisle
     
    2727//-----------------------------------------------------------------------------
    2828// Forward declarations
    29 static inline void __set_owner ( monitor_desc * this, thread_desc * owner );
    30 static inline void __set_owner ( monitor_desc * storage [], __lock_size_t count, thread_desc * owner );
    31 static inline void set_mask  ( monitor_desc * storage [], __lock_size_t count, const __waitfor_mask_t & mask );
    32 static inline void reset_mask( monitor_desc * this );
    33 
    34 static inline thread_desc * next_thread( monitor_desc * this );
    35 static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & monitors );
     29static inline void __set_owner ( $monitor * this, $thread * owner );
     30static inline void __set_owner ( $monitor * storage [], __lock_size_t count, $thread * owner );
     31static inline void set_mask  ( $monitor * storage [], __lock_size_t count, const __waitfor_mask_t & mask );
     32static inline void reset_mask( $monitor * this );
     33
     34static inline $thread * next_thread( $monitor * this );
     35static inline bool is_accepted( $monitor * this, const __monitor_group_t & monitors );
    3636
    3737static inline void lock_all  ( __spinlock_t * locks [], __lock_size_t count );
    38 static inline void lock_all  ( monitor_desc * source [], __spinlock_t * /*out*/ locks [], __lock_size_t count );
     38static inline void lock_all  ( $monitor * source [], __spinlock_t * /*out*/ locks [], __lock_size_t count );
    3939static inline void unlock_all( __spinlock_t * locks [], __lock_size_t count );
    40 static inline void unlock_all( monitor_desc * locks [], __lock_size_t count );
    41 
    42 static inline void save   ( monitor_desc * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*out*/ recursions [], __waitfor_mask_t /*out*/ masks [] );
    43 static inline void restore( monitor_desc * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*in */ recursions [], __waitfor_mask_t /*in */ masks [] );
    44 
    45 static inline void init     ( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );
    46 static inline void init_push( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );
    47 
    48 static inline thread_desc *        check_condition   ( __condition_criterion_t * );
     40static inline void unlock_all( $monitor * locks [], __lock_size_t count );
     41
     42static inline void save   ( $monitor * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*out*/ recursions [], __waitfor_mask_t /*out*/ masks [] );
     43static inline void restore( $monitor * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*in */ recursions [], __waitfor_mask_t /*in */ masks [] );
     44
     45static inline void init     ( __lock_size_t count, $monitor * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );
     46static inline void init_push( __lock_size_t count, $monitor * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );
     47
     48static inline $thread *        check_condition   ( __condition_criterion_t * );
    4949static inline void                 brand_condition   ( condition & );
    50 static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t &, monitor_desc * monitors [], __lock_size_t count );
     50static inline [$thread *, int] search_entry_queue( const __waitfor_mask_t &, $monitor * monitors [], __lock_size_t count );
    5151
    5252forall(dtype T | sized( T ))
    5353static inline __lock_size_t insert_unique( T * array [], __lock_size_t & size, T * val );
    5454static inline __lock_size_t count_max    ( const __waitfor_mask_t & mask );
    55 static inline __lock_size_t aggregate    ( monitor_desc * storage [], const __waitfor_mask_t & mask );
     55static inline __lock_size_t aggregate    ( $monitor * storage [], const __waitfor_mask_t & mask );
    5656
    5757//-----------------------------------------------------------------------------
     
    6868
    6969#define monitor_ctx( mons, cnt )                                /* Define that create the necessary struct for internal/external scheduling operations */ \
    70         monitor_desc ** monitors = mons;                          /* Save the targeted monitors                                                          */ \
     70        $monitor ** monitors = mons;                          /* Save the targeted monitors                                                          */ \
    7171        __lock_size_t count = cnt;                                /* Save the count to a local variable                                                  */ \
    7272        unsigned int recursions[ count ];                         /* Save the current recursion levels to restore them later                             */ \
     
    8181// Enter/Leave routines
    8282// Enter single monitor
    83 static void __enter( monitor_desc * this, const __monitor_group_t & group ) {
     83static void __enter( $monitor * this, const __monitor_group_t & group ) {
    8484        // Lock the monitor spinlock
    8585        lock( this->lock __cfaabi_dbg_ctx2 );
    8686        // Interrupts disable inside critical section
    87         thread_desc * thrd = kernelTLS.this_thread;
     87        $thread * thrd = kernelTLS.this_thread;
    8888
    8989        __cfaabi_dbg_print_safe( "Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner);
     
    137137}
    138138
    139 static void __dtor_enter( monitor_desc * this, fptr_t func ) {
     139static void __dtor_enter( $monitor * this, fptr_t func ) {
    140140        // Lock the monitor spinlock
    141141        lock( this->lock __cfaabi_dbg_ctx2 );
    142142        // Interrupts disable inside critical section
    143         thread_desc * thrd = kernelTLS.this_thread;
     143        $thread * thrd = kernelTLS.this_thread;
    144144
    145145        __cfaabi_dbg_print_safe( "Kernel : %10p Entering dtor for mon %p (%p)\n", thrd, this, this->owner);
     
    164164
    165165        __lock_size_t count = 1;
    166         monitor_desc ** monitors = &this;
     166        $monitor ** monitors = &this;
    167167        __monitor_group_t group = { &this, 1, func };
    168168        if( is_accepted( this, group) ) {
     
    216216
    217217// Leave single monitor
    218 void __leave( monitor_desc * this ) {
     218void __leave( $monitor * this ) {
    219219        // Lock the monitor spinlock
    220220        lock( this->lock __cfaabi_dbg_ctx2 );
     
    236236
    237237        // Get the next thread, will be null on low contention monitor
    238         thread_desc * new_owner = next_thread( this );
     238        $thread * new_owner = next_thread( this );
    239239
    240240        // Check the new owner is consistent with who we wake-up
     
    251251
    252252// Leave single monitor for the last time
    253 void __dtor_leave( monitor_desc * this ) {
     253void __dtor_leave( $monitor * this ) {
    254254        __cfaabi_dbg_debug_do(
    255255                if( TL_GET( this_thread ) != this->owner ) {
     
    267267        // Should never return
    268268        void __cfactx_thrd_leave() {
    269                 thread_desc * thrd = TL_GET( this_thread );
    270                 monitor_desc * this = &thrd->self_mon;
     269                $thread * thrd = TL_GET( this_thread );
     270                $monitor * this = &thrd->self_mon;
    271271
    272272                // Lock the monitor now
     
    287287
    288288                // Fetch the next thread, can be null
    289                 thread_desc * new_owner = next_thread( this );
     289                $thread * new_owner = next_thread( this );
    290290
    291291                // Release the monitor lock
     
    317317// Leave multiple monitor
    318318// relies on the monitor array being sorted
    319 static inline void leave(monitor_desc * monitors [], __lock_size_t count) {
     319static inline void leave($monitor * monitors [], __lock_size_t count) {
    320320        for( __lock_size_t i = count - 1; i >= 0; i--) {
    321321                __leave( monitors[i] );
     
    325325// Ctor for monitor guard
    326326// Sorts monitors before entering
    327 void ?{}( monitor_guard_t & this, monitor_desc * m [], __lock_size_t count, fptr_t func ) {
    328         thread_desc * thrd = TL_GET( this_thread );
     327void ?{}( monitor_guard_t & this, $monitor * m [], __lock_size_t count, fptr_t func ) {
     328        $thread * thrd = TL_GET( this_thread );
    329329
    330330        // Store current array
     
    366366// Ctor for monitor guard
    367367// Sorts monitors before entering
    368 void ?{}( monitor_dtor_guard_t & this, monitor_desc * m [], fptr_t func ) {
     368void ?{}( monitor_dtor_guard_t & this, $monitor * m [], fptr_t func ) {
    369369        // optimization
    370         thread_desc * thrd = TL_GET( this_thread );
     370        $thread * thrd = TL_GET( this_thread );
    371371
    372372        // Store current array
     
    393393//-----------------------------------------------------------------------------
    394394// Internal scheduling types
    395 void ?{}(__condition_node_t & this, thread_desc * waiting_thread, __lock_size_t count, uintptr_t user_info ) {
     395void ?{}(__condition_node_t & this, $thread * waiting_thread, __lock_size_t count, uintptr_t user_info ) {
    396396        this.waiting_thread = waiting_thread;
    397397        this.count = count;
     
    407407}
    408408
    409 void ?{}(__condition_criterion_t & this, monitor_desc * target, __condition_node_t & owner ) {
     409void ?{}(__condition_criterion_t & this, $monitor * target, __condition_node_t & owner ) {
    410410        this.ready  = false;
    411411        this.target = target;
     
    441441        // Find the next thread(s) to run
    442442        __lock_size_t thread_count = 0;
    443         thread_desc * threads[ count ];
     443        $thread * threads[ count ];
    444444        __builtin_memset( threads, 0, sizeof( threads ) );
    445445
     
    449449        // Remove any duplicate threads
    450450        for( __lock_size_t i = 0; i < count; i++) {
    451                 thread_desc * new_owner = next_thread( monitors[i] );
     451                $thread * new_owner = next_thread( monitors[i] );
    452452                insert_unique( threads, thread_count, new_owner );
    453453        }
     
    479479        //Some more checking in debug
    480480        __cfaabi_dbg_debug_do(
    481                 thread_desc * this_thrd = TL_GET( this_thread );
     481                $thread * this_thrd = TL_GET( this_thread );
    482482                if ( this.monitor_count != this_thrd->monitors.size ) {
    483483                        abort( "Signal on condition %p made with different number of monitor(s), expected %zi got %zi", &this, this.monitor_count, this_thrd->monitors.size );
     
    533533
    534534        //Find the thread to run
    535         thread_desc * signallee = pop_head( this.blocked )->waiting_thread;
     535        $thread * signallee = pop_head( this.blocked )->waiting_thread;
    536536        /* paranoid */ verify( signallee->next == 0p );
    537537        __set_owner( monitors, count, signallee );
     
    587587        // Create one!
    588588        __lock_size_t max = count_max( mask );
    589         monitor_desc * mon_storage[max];
     589        $monitor * mon_storage[max];
    590590        __builtin_memset( mon_storage, 0, sizeof( mon_storage ) );
    591591        __lock_size_t actual_count = aggregate( mon_storage, mask );
     
    605605        {
    606606                // Check if the entry queue
    607                 thread_desc * next; int index;
     607                $thread * next; int index;
    608608                [next, index] = search_entry_queue( mask, monitors, count );
    609609
     
    615615                                verifyf( accepted.size == 1,  "ERROR: Accepted dtor has more than 1 mutex parameter." );
    616616
    617                                 monitor_desc * mon2dtor = accepted[0];
     617                                $monitor * mon2dtor = accepted[0];
    618618                                verifyf( mon2dtor->dtor_node, "ERROR: Accepted monitor has no dtor_node." );
    619619
     
    709709// Utilities
    710710
    711 static inline void __set_owner( monitor_desc * this, thread_desc * owner ) {
     711static inline void __set_owner( $monitor * this, $thread * owner ) {
    712712        /* paranoid */ verify( this->lock.lock );
    713713
     
    719719}
    720720
    721 static inline void __set_owner( monitor_desc * monitors [], __lock_size_t count, thread_desc * owner ) {
     721static inline void __set_owner( $monitor * monitors [], __lock_size_t count, $thread * owner ) {
    722722        /* paranoid */ verify ( monitors[0]->lock.lock );
    723723        /* paranoid */ verifyf( monitors[0]->owner == kernelTLS.this_thread, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, monitors[0]->owner, monitors[0]->recursion, monitors[0] );
     
    732732}
    733733
    734 static inline void set_mask( monitor_desc * storage [], __lock_size_t count, const __waitfor_mask_t & mask ) {
     734static inline void set_mask( $monitor * storage [], __lock_size_t count, const __waitfor_mask_t & mask ) {
    735735        for( __lock_size_t i = 0; i < count; i++) {
    736736                storage[i]->mask = mask;
     
    738738}
    739739
    740 static inline void reset_mask( monitor_desc * this ) {
     740static inline void reset_mask( $monitor * this ) {
    741741        this->mask.accepted = 0p;
    742742        this->mask.data = 0p;
     
    744744}
    745745
    746 static inline thread_desc * next_thread( monitor_desc * this ) {
     746static inline $thread * next_thread( $monitor * this ) {
    747747        //Check the signaller stack
    748748        __cfaabi_dbg_print_safe( "Kernel :  mon %p AS-stack top %p\n", this, this->signal_stack.top);
     
    760760        // No signaller thread
    761761        // Get the next thread in the entry_queue
    762         thread_desc * new_owner = pop_head( this->entry_queue );
     762        $thread * new_owner = pop_head( this->entry_queue );
    763763        /* paranoid */ verifyf( !this->owner || kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this );
    764764        /* paranoid */ verify( !new_owner || new_owner->next == 0p );
     
    768768}
    769769
    770 static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & group ) {
     770static inline bool is_accepted( $monitor * this, const __monitor_group_t & group ) {
    771771        __acceptable_t * it = this->mask.data; // Optim
    772772        __lock_size_t count = this->mask.size;
     
    790790}
    791791
    792 static inline void init( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {
     792static inline void init( __lock_size_t count, $monitor * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {
    793793        for( __lock_size_t i = 0; i < count; i++) {
    794794                (criteria[i]){ monitors[i], waiter };
     
    798798}
    799799
    800 static inline void init_push( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {
     800static inline void init_push( __lock_size_t count, $monitor * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {
    801801        for( __lock_size_t i = 0; i < count; i++) {
    802802                (criteria[i]){ monitors[i], waiter };
     
    814814}
    815815
    816 static inline void lock_all( monitor_desc * source [], __spinlock_t * /*out*/ locks [], __lock_size_t count ) {
     816static inline void lock_all( $monitor * source [], __spinlock_t * /*out*/ locks [], __lock_size_t count ) {
    817817        for( __lock_size_t i = 0; i < count; i++ ) {
    818818                __spinlock_t * l = &source[i]->lock;
     
    828828}
    829829
    830 static inline void unlock_all( monitor_desc * locks [], __lock_size_t count ) {
     830static inline void unlock_all( $monitor * locks [], __lock_size_t count ) {
    831831        for( __lock_size_t i = 0; i < count; i++ ) {
    832832                unlock( locks[i]->lock );
     
    835835
    836836static inline void save(
    837         monitor_desc * ctx [],
     837        $monitor * ctx [],
    838838        __lock_size_t count,
    839839        __attribute((unused)) __spinlock_t * locks [],
     
    848848
    849849static inline void restore(
    850         monitor_desc * ctx [],
     850        $monitor * ctx [],
    851851        __lock_size_t count,
    852852        __spinlock_t * locks [],
     
    866866// 2 - Checks if all the monitors are ready to run
    867867//     if so return the thread to run
    868 static inline thread_desc * check_condition( __condition_criterion_t * target ) {
     868static inline $thread * check_condition( __condition_criterion_t * target ) {
    869869        __condition_node_t * node = target->owner;
    870870        unsigned short count = node->count;
     
    889889
    890890static inline void brand_condition( condition & this ) {
    891         thread_desc * thrd = TL_GET( this_thread );
     891        $thread * thrd = TL_GET( this_thread );
    892892        if( !this.monitors ) {
    893893                // __cfaabi_dbg_print_safe( "Branding\n" );
     
    895895                this.monitor_count = thrd->monitors.size;
    896896
    897                 this.monitors = (monitor_desc **)malloc( this.monitor_count * sizeof( *this.monitors ) );
     897                this.monitors = ($monitor **)malloc( this.monitor_count * sizeof( *this.monitors ) );
    898898                for( int i = 0; i < this.monitor_count; i++ ) {
    899899                        this.monitors[i] = thrd->monitors[i];
     
    902902}
    903903
    904 static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t & mask, monitor_desc * monitors [], __lock_size_t count ) {
    905 
    906         __queue_t(thread_desc) & entry_queue = monitors[0]->entry_queue;
     904static inline [$thread *, int] search_entry_queue( const __waitfor_mask_t & mask, $monitor * monitors [], __lock_size_t count ) {
     905
     906        __queue_t($thread) & entry_queue = monitors[0]->entry_queue;
    907907
    908908        // For each thread in the entry-queue
    909         for(    thread_desc ** thrd_it = &entry_queue.head;
     909        for(    $thread ** thrd_it = &entry_queue.head;
    910910                *thrd_it != 1p;
    911911                thrd_it = &(*thrd_it)->next
     
    951951}
    952952
    953 static inline __lock_size_t aggregate( monitor_desc * storage [], const __waitfor_mask_t & mask ) {
     953static inline __lock_size_t aggregate( $monitor * storage [], const __waitfor_mask_t & mask ) {
    954954        __lock_size_t size = 0;
    955955        for( __lock_size_t i = 0; i < mask.size; i++ ) {
  • libcfa/src/concurrency/monitor.hfa

    r0f2c555 rac2b598  
    2323
    2424trait is_monitor(dtype T) {
    25         monitor_desc * get_monitor( T & );
     25        $monitor * get_monitor( T & );
    2626        void ^?{}( T & mutex );
    2727};
    2828
    29 static inline void ?{}(monitor_desc & this) with( this ) {
     29static inline void ?{}($monitor & this) with( this ) {
    3030        lock{};
    3131        entry_queue{};
     
    3939}
    4040
    41 static inline void ^?{}(monitor_desc & ) {}
     41static inline void ^?{}($monitor & ) {}
    4242
    4343struct monitor_guard_t {
    44         monitor_desc **         m;
     44        $monitor **     m;
    4545        __lock_size_t           count;
    4646        __monitor_group_t prev;
    4747};
    4848
    49 void ?{}( monitor_guard_t & this, monitor_desc ** m, __lock_size_t count, void (*func)() );
     49void ?{}( monitor_guard_t & this, $monitor ** m, __lock_size_t count, void (*func)() );
    5050void ^?{}( monitor_guard_t & this );
    5151
    5252struct monitor_dtor_guard_t {
    53         monitor_desc *    m;
     53        $monitor *    m;
    5454        __monitor_group_t prev;
    5555};
    5656
    57 void ?{}( monitor_dtor_guard_t & this, monitor_desc ** m, void (*func)() );
     57void ?{}( monitor_dtor_guard_t & this, $monitor ** m, void (*func)() );
    5858void ^?{}( monitor_dtor_guard_t & this );
    5959
     
    7272
    7373        // The monitor this criterion concerns
    74         monitor_desc * target;
     74        $monitor * target;
    7575
    7676        // The parent node to which this criterion belongs
     
    8787struct __condition_node_t {
    8888        // Thread that needs to be woken when all criteria are met
    89         thread_desc * waiting_thread;
     89        $thread * waiting_thread;
    9090
    9191        // Array of criteria (Criterions are contiguous in memory)
     
    106106}
    107107
    108 void ?{}(__condition_node_t & this, thread_desc * waiting_thread, __lock_size_t count, uintptr_t user_info );
     108void ?{}(__condition_node_t & this, $thread * waiting_thread, __lock_size_t count, uintptr_t user_info );
    109109void ?{}(__condition_criterion_t & this );
    110 void ?{}(__condition_criterion_t & this, monitor_desc * target, __condition_node_t * owner );
     110void ?{}(__condition_criterion_t & this, $monitor * target, __condition_node_t * owner );
    111111
    112112struct condition {
     
    115115
    116116        // Array of monitor pointers (Monitors are NOT contiguous in memory)
    117         monitor_desc ** monitors;
     117        $monitor ** monitors;
    118118
    119119        // Number of monitors in the array
  • libcfa/src/concurrency/mutex.cfa

    r0f2c555 rac2b598  
    120120        recursion_count--;
    121121        if( recursion_count == 0 ) {
    122                 thread_desc * thrd = pop_head( blocked_threads );
     122                $thread * thrd = pop_head( blocked_threads );
    123123                owner = thrd;
    124124                recursion_count = (thrd ? 1 : 0);
  • libcfa/src/concurrency/mutex.hfa

    r0f2c555 rac2b598  
    3636
    3737        // List of blocked threads
    38         __queue_t(struct thread_desc) blocked_threads;
     38        __queue_t(struct $thread) blocked_threads;
    3939
    4040        // Locked flag
     
    5555
    5656        // List of blocked threads
    57         __queue_t(struct thread_desc) blocked_threads;
     57        __queue_t(struct $thread) blocked_threads;
    5858
    5959        // Current thread owning the lock
    60         struct thread_desc * owner;
     60        struct $thread * owner;
    6161
    6262        // Number of recursion level
     
    8383
    8484        // List of blocked threads
    85         __queue_t(struct thread_desc) blocked_threads;
     85        __queue_t(struct $thread) blocked_threads;
    8686};
    8787
  • libcfa/src/concurrency/preemption.cfa

    r0f2c555 rac2b598  
    3939// FwdDeclarations : timeout handlers
    4040static void preempt( processor   * this );
    41 static void timeout( thread_desc * this );
     41static void timeout( $thread * this );
    4242
    4343// FwdDeclarations : Signal handlers
     
    267267
    268268// reserved for future use
    269 static void timeout( thread_desc * this ) {
     269static void timeout( $thread * this ) {
    270270        //TODO : implement waking threads
    271271}
  • libcfa/src/concurrency/thread.cfa

    r0f2c555 rac2b598  
    2525//-----------------------------------------------------------------------------
    2626// Thread ctors and dtors
    27 void ?{}(thread_desc & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
     27void ?{}($thread & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
    2828        context{ 0p, 0p };
    2929        self_cor{ name, storage, storageSize };
     
    4444}
    4545
    46 void ^?{}(thread_desc& this) with( this ) {
     46void ^?{}($thread& this) with( this ) {
    4747        unregister(curr_cluster, this);
    4848        ^self_cor{};
     
    5353forall( dtype T | is_thread(T) )
    5454void __thrd_start( T & this, void (*main_p)(T &) ) {
    55         thread_desc * this_thrd = get_thread(this);
     55        $thread * this_thrd = get_thread(this);
    5656
    5757        disable_interrupts();
  • libcfa/src/concurrency/thread.hfa

    r0f2c555 rac2b598  
    2828      void ^?{}(T& mutex this);
    2929      void main(T& this);
    30       thread_desc* get_thread(T& this);
     30      $thread* get_thread(T& this);
    3131};
    3232
    3333// define that satisfies the trait without using the thread keyword
    34 #define DECL_THREAD(X) thread_desc* get_thread(X& this) __attribute__((const)) { return &this.__thrd; } void main(X& this)
     34#define DECL_THREAD(X) $thread* get_thread(X& this) __attribute__((const)) { return &this.__thrd; } void main(X& this)
    3535
    3636// Inline getters for threads/coroutines/monitors
    3737forall( dtype T | is_thread(T) )
    38 static inline coroutine_desc* get_coroutine(T & this) __attribute__((const)) { return &get_thread(this)->self_cor; }
     38static inline $coroutine* get_coroutine(T & this) __attribute__((const)) { return &get_thread(this)->self_cor; }
    3939
    4040forall( dtype T | is_thread(T) )
    41 static inline monitor_desc  * get_monitor  (T & this) __attribute__((const)) { return &get_thread(this)->self_mon; }
     41static inline $monitor  * get_monitor  (T & this) __attribute__((const)) { return &get_thread(this)->self_mon; }
    4242
    43 static inline coroutine_desc* get_coroutine(thread_desc * this) __attribute__((const)) { return &this->self_cor; }
    44 static inline monitor_desc  * get_monitor  (thread_desc * this) __attribute__((const)) { return &this->self_mon; }
     43static inline $coroutine* get_coroutine($thread * this) __attribute__((const)) { return &this->self_cor; }
     44static inline $monitor  * get_monitor  ($thread * this) __attribute__((const)) { return &this->self_mon; }
    4545
    4646//-----------------------------------------------------------------------------
     
    5353//-----------------------------------------------------------------------------
    5454// Ctors and dtors
    55 void ?{}(thread_desc & this, const char * const name, struct cluster & cl, void * storage, size_t storageSize );
    56 void ^?{}(thread_desc & this);
     55void ?{}($thread & this, const char * const name, struct cluster & cl, void * storage, size_t storageSize );
     56void ^?{}($thread & this);
    5757
    58 static inline void ?{}(thread_desc & this)                                                                  { this{ "Anonymous Thread", *mainCluster, 0p, 65000 }; }
    59 static inline void ?{}(thread_desc & this, size_t stackSize )                                               { this{ "Anonymous Thread", *mainCluster, 0p, stackSize }; }
    60 static inline void ?{}(thread_desc & this, void * storage, size_t storageSize )                             { this{ "Anonymous Thread", *mainCluster, storage, storageSize }; }
    61 static inline void ?{}(thread_desc & this, struct cluster & cl )                                            { this{ "Anonymous Thread", cl, 0p, 65000 }; }
    62 static inline void ?{}(thread_desc & this, struct cluster & cl, size_t stackSize )                          { this{ "Anonymous Thread", cl, 0p, stackSize }; }
    63 static inline void ?{}(thread_desc & this, struct cluster & cl, void * storage, size_t storageSize )        { this{ "Anonymous Thread", cl, storage, storageSize }; }
    64 static inline void ?{}(thread_desc & this, const char * const name)                                         { this{ name, *mainCluster, 0p, 65000 }; }
    65 static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl )                   { this{ name, cl, 0p, 65000 }; }
    66 static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl, size_t stackSize ) { this{ name, cl, 0p, stackSize }; }
     58static inline void ?{}($thread & this)                                                                  { this{ "Anonymous Thread", *mainCluster, 0p, 65000 }; }
     59static inline void ?{}($thread & this, size_t stackSize )                                               { this{ "Anonymous Thread", *mainCluster, 0p, stackSize }; }
     60static inline void ?{}($thread & this, void * storage, size_t storageSize )                             { this{ "Anonymous Thread", *mainCluster, storage, storageSize }; }
     61static inline void ?{}($thread & this, struct cluster & cl )                                            { this{ "Anonymous Thread", cl, 0p, 65000 }; }
     62static inline void ?{}($thread & this, struct cluster & cl, size_t stackSize )                          { this{ "Anonymous Thread", cl, 0p, stackSize }; }
     63static inline void ?{}($thread & this, struct cluster & cl, void * storage, size_t storageSize )        { this{ "Anonymous Thread", cl, storage, storageSize }; }
     64static inline void ?{}($thread & this, const char * const name)                                         { this{ name, *mainCluster, 0p, 65000 }; }
     65static inline void ?{}($thread & this, const char * const name, struct cluster & cl )                   { this{ name, cl, 0p, 65000 }; }
     66static inline void ?{}($thread & this, const char * const name, struct cluster & cl, size_t stackSize ) { this{ name, cl, 0p, stackSize }; }
    6767
    6868//-----------------------------------------------------------------------------
     
    8585//-----------------------------------------------------------------------------
    8686// Thread getters
    87 static inline struct thread_desc * active_thread () { return TL_GET( this_thread ); }
     87static inline struct $thread * active_thread () { return TL_GET( this_thread ); }
    8888
    8989//-----------------------------------------------------------------------------
     
    9797// Unpark a thread, if the thread is already blocked, schedule it
    9898//                  if the thread is not yet block, signal that it should rerun immediately
    99 void unpark( thread_desc * this );
     99void unpark( $thread * this );
    100100
    101101forall( dtype T | is_thread(T) )
  • src/Concurrency/Keywords.cc

    r0f2c555 rac2b598  
    8888        //      int data;                                  int data;
    8989        //      a_struct_t more_data;                      a_struct_t more_data;
    90         //                                =>             thread_desc __thrd_d;
     90        //                                =>             $thread __thrd_d;
    9191        // };                                        };
    92         //                                           static inline thread_desc * get_thread( MyThread * this ) { return &this->__thrd_d; }
     92        //                                           static inline $thread * get_thread( MyThread * this ) { return &this->__thrd_d; }
    9393        //
    9494        class ThreadKeyword final : public ConcurrentSueKeyword {
     
    9696
    9797                ThreadKeyword() : ConcurrentSueKeyword(
    98                         "thread_desc",
     98                        "$thread",
    9999                        "__thrd",
    100100                        "get_thread",
     
    120120        //      int data;                                  int data;
    121121        //      a_struct_t more_data;                      a_struct_t more_data;
    122         //                                =>             coroutine_desc __cor_d;
     122        //                                =>             $coroutine __cor_d;
    123123        // };                                        };
    124         //                                           static inline coroutine_desc * get_coroutine( MyCoroutine * this ) { return &this->__cor_d; }
     124        //                                           static inline $coroutine * get_coroutine( MyCoroutine * this ) { return &this->__cor_d; }
    125125        //
    126126        class CoroutineKeyword final : public ConcurrentSueKeyword {
     
    128128
    129129                CoroutineKeyword() : ConcurrentSueKeyword(
    130                         "coroutine_desc",
     130                        "$coroutine",
    131131                        "__cor",
    132132                        "get_coroutine",
     
    152152        //      int data;                                  int data;
    153153        //      a_struct_t more_data;                      a_struct_t more_data;
    154         //                                =>             monitor_desc __mon_d;
     154        //                                =>             $monitor __mon_d;
    155155        // };                                        };
    156         //                                           static inline monitor_desc * get_coroutine( MyMonitor * this ) { return &this->__cor_d; }
     156        //                                           static inline $monitor * get_coroutine( MyMonitor * this ) { return &this->__cor_d; }
    157157        //
    158158        class MonitorKeyword final : public ConcurrentSueKeyword {
     
    160160
    161161                MonitorKeyword() : ConcurrentSueKeyword(
    162                         "monitor_desc",
     162                        "$monitor",
    163163                        "__mon",
    164164                        "get_monitor",
     
    182182        //Handles mutex routines definitions :
    183183        // void foo( A * mutex a, B * mutex b,  int i ) {                  void foo( A * a, B * b,  int i ) {
    184         //                                                                       monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) };
     184        //                                                                       $monitor * __monitors[] = { get_monitor(a), get_monitor(b) };
    185185        //                                                                       monitor_guard_t __guard = { __monitors, 2 };
    186186        //    /*Some code*/                                       =>           /*Some code*/
     
    221221        //Handles mutex routines definitions :
    222222        // void foo( A * mutex a, B * mutex b,  int i ) {                  void foo( A * a, B * b,  int i ) {
    223         //                                                                       monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) };
     223        //                                                                       $monitor * __monitors[] = { get_monitor(a), get_monitor(b) };
    224224        //                                                                       monitor_guard_t __guard = { __monitors, 2 };
    225225        //    /*Some code*/                                       =>           /*Some code*/
     
    306306        Expression * ConcurrentSueKeyword::postmutate( KeywordCastExpr * cast ) {
    307307                if ( cast_target == cast->target ) {
    308                         // convert (thread &)t to (thread_desc &)*get_thread(t), etc.
     308                        // convert (thread &)t to ($thread &)*get_thread(t), etc.
    309309                        if( !type_decl ) SemanticError( cast, context_error );
    310310                        if( !dtor_decl ) SemanticError( cast, context_error );
     
    516516        void MutexKeyword::postvisit(StructDecl* decl) {
    517517
    518                 if( decl->name == "monitor_desc" && decl->body ) {
     518                if( decl->name == "$monitor" && decl->body ) {
    519519                        assert( !monitor_decl );
    520520                        monitor_decl = decl;
     
    612612                );
    613613
    614                 //monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) };
     614                //$monitor * __monitors[] = { get_monitor(a), get_monitor(b) };
    615615                body->push_front( new DeclStmt( monitors) );
    616616        }
     
    673673                );
    674674
    675                 //monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) };
     675                //$monitor * __monitors[] = { get_monitor(a), get_monitor(b) };
    676676                body->push_front( new DeclStmt( monitors) );
    677677        }
     
    681681        //=============================================================================================
    682682        void ThreadStarter::previsit( StructDecl * decl ) {
    683                 if( decl->name == "thread_desc" && decl->body ) {
     683                if( decl->name == "$thread" && decl->body ) {
    684684                        assert( !thread_decl );
    685685                        thread_decl = decl;
  • src/Concurrency/Waitfor.cc

    r0f2c555 rac2b598  
    244244                        decl_mask = decl;
    245245                }
    246                 else if( decl->name == "monitor_desc" ) {
     246                else if( decl->name == "$monitor" ) {
    247247                        assert( !decl_monitor );
    248248                        decl_monitor = decl;
  • src/ResolvExpr/AlternativeFinder.cc

    r0f2c555 rac2b598  
    12921292
    12931293                try {
    1294                         // Attempt 1 : turn (thread&)X into (thread_desc&)X.__thrd
     1294                        // Attempt 1 : turn (thread&)X into ($thread&)X.__thrd
    12951295                        // Clone is purely for memory management
    12961296                        std::unique_ptr<Expression> tech1 { new UntypedMemberExpr(new NameExpr(castExpr->concrete_target.field), castExpr->arg->clone()) };
     
    13031303                } catch(SemanticErrorException & ) {}
    13041304
    1305                 // Fallback : turn (thread&)X into (thread_desc&)get_thread(X)
     1305                // Fallback : turn (thread&)X into ($thread&)get_thread(X)
    13061306                std::unique_ptr<Expression> fallback { UntypedExpr::createDeref( new UntypedExpr(new NameExpr(castExpr->concrete_target.getter), { castExpr->arg->clone() })) };
    13071307                // don't prune here, since it's guaranteed all alternatives will have the same type
Note: See TracChangeset for help on using the changeset viewer.