Ignore:
Timestamp:
Jul 5, 2021, 4:44:20 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
7f62b708
Parents:
ee23a8d
Message:

Step 1 of changing $thread to thread$

Location:
libcfa/src/concurrency/kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel/fwd.hfa

    ree23a8d re84ab3d  
    2424#endif
    2525
    26 struct $thread;
     26struct thread$;
    2727struct processor;
    2828struct cluster;
     
    3636        extern "Cforall" {
    3737                extern __attribute__((aligned(128))) thread_local struct KernelThreadData {
    38                         struct $thread          * volatile this_thread;
     38                        struct thread$          * volatile this_thread;
    3939                        struct processor        * volatile this_processor;
    4040                        volatile bool sched_lock;
     
    120120        extern "Cforall" {
    121121                extern void park( void );
    122                 extern void unpark( struct $thread * this );
    123                 static inline struct $thread * active_thread () {
    124                         struct $thread * t = publicTLS_get( this_thread );
     122                extern void unpark( struct thread$ * this );
     123                static inline struct thread$ * active_thread () {
     124                        struct thread$ * t = publicTLS_get( this_thread );
    125125                        /* paranoid */ verify( t );
    126126                        return t;
     
    144144                // Semaphore which only supports a single thread
    145145                struct single_sem {
    146                         struct $thread * volatile ptr;
     146                        struct thread$ * volatile ptr;
    147147                };
    148148
     
    156156                        bool wait(single_sem & this) {
    157157                                for() {
    158                                         struct $thread * expected = this.ptr;
     158                                        struct thread$ * expected = this.ptr;
    159159                                        if(expected == 1p) {
    160160                                                if(__atomic_compare_exchange_n(&this.ptr, &expected, 0p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
     
    175175                        bool post(single_sem & this) {
    176176                                for() {
    177                                         struct $thread * expected = this.ptr;
     177                                        struct thread$ * expected = this.ptr;
    178178                                        if(expected == 1p) return false;
    179179                                        if(expected == 0p) {
     
    200200                        //     1p     : fulfilled (wait won't block)
    201201                        // any thread : a thread is currently waiting
    202                         struct $thread * volatile ptr;
     202                        struct thread$ * volatile ptr;
    203203                };
    204204
     
    214214                        bool wait(oneshot & this) {
    215215                                for() {
    216                                         struct $thread * expected = this.ptr;
     216                                        struct thread$ * expected = this.ptr;
    217217                                        if(expected == 1p) return false;
    218218                                        /* paranoid */ verify( expected == 0p );
     
    227227                        // Mark as fulfilled, wake thread if needed
    228228                        // return true if a thread was unparked
    229                         $thread * post(oneshot & this, bool do_unpark = true) {
    230                                 struct $thread * got = __atomic_exchange_n( &this.ptr, 1p, __ATOMIC_SEQ_CST);
     229                        thread$ * post(oneshot & this, bool do_unpark = true) {
     230                                struct thread$ * got = __atomic_exchange_n( &this.ptr, 1p, __ATOMIC_SEQ_CST);
    231231                                if( got == 0p ) return 0p;
    232232                                if(do_unpark) unpark( got );
     
    343343                        // from the server side, mark the future as fulfilled
    344344                        // delete it if needed
    345                         $thread * fulfil( future_t & this, bool do_unpark = true  ) {
     345                        thread$ * fulfil( future_t & this, bool do_unpark = true  ) {
    346346                                for() {
    347347                                        struct oneshot * expected = this.ptr;
     
    364364                                        if(__atomic_compare_exchange_n(&this.ptr, &expected, want, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    365365                                                if( expected == 0p ) { /* paranoid */ verify( this.ptr == 1p); return 0p; }
    366                                                 $thread * ret = post( *expected, do_unpark );
     366                                                thread$ * ret = post( *expected, do_unpark );
    367367                                                __atomic_store_n( &this.ptr, 1p, __ATOMIC_SEQ_CST);
    368368                                                return ret;
  • libcfa/src/concurrency/kernel/startup.cfa

    ree23a8d re84ab3d  
    7777static void __kernel_first_resume( processor * this );
    7878static void __kernel_last_resume ( processor * this );
    79 static void init(processor & this, const char name[], cluster & _cltr, $thread * initT);
     79static void init(processor & this, const char name[], cluster & _cltr, thread$ * initT);
    8080static void deinit(processor & this);
    8181static void doregister( struct cluster & cltr );
     
    8383static void register_tls( processor * this );
    8484static void unregister_tls( processor * this );
    85 static void ?{}( $coroutine & this, current_stack_info_t * info);
    86 static void ?{}( $thread & this, current_stack_info_t * info);
     85static void ?{}( coroutine$ & this, current_stack_info_t * info);
     86static void ?{}( thread$ & this, current_stack_info_t * info);
    8787static void ?{}(processorCtx_t & this) {}
    8888static void ?{}(processorCtx_t & this, processor * proc, current_stack_info_t * info);
     
    105105KERNEL_STORAGE(cluster,              mainCluster);
    106106KERNEL_STORAGE(processor,            mainProcessor);
    107 KERNEL_STORAGE($thread,              mainThread);
     107KERNEL_STORAGE(thread$,              mainThread);
    108108KERNEL_STORAGE(__stack_t,            mainThreadCtx);
    109109KERNEL_STORAGE(__scheduler_RWLock_t, __scheduler_lock);
     
    114114cluster              * mainCluster;
    115115processor            * mainProcessor;
    116 $thread              * mainThread;
     116thread$              * mainThread;
    117117__scheduler_RWLock_t * __scheduler_lock;
    118118
     
    203203        // SKULLDUGGERY: the mainThread steals the process main thread
    204204        // which will then be scheduled by the mainProcessor normally
    205         mainThread = ($thread *)&storage_mainThread;
     205        mainThread = (thread$ *)&storage_mainThread;
    206206        current_stack_info_t info;
    207207        info.storage = (__stack_t*)&storage_mainThreadCtx;
     
    397397
    398398static void __kernel_first_resume( processor * this ) {
    399         $thread * src = mainThread;
    400         $coroutine * dst = get_coroutine(this->runner);
     399        thread$ * src = mainThread;
     400        coroutine$ * dst = get_coroutine(this->runner);
    401401
    402402        /* paranoid */ verify( ! __preemption_enabled() );
     
    430430// KERNEL_ONLY
    431431static void __kernel_last_resume( processor * this ) {
    432         $coroutine * src = &mainThread->self_cor;
    433         $coroutine * dst = get_coroutine(this->runner);
     432        coroutine$ * src = &mainThread->self_cor;
     433        coroutine$ * dst = get_coroutine(this->runner);
    434434
    435435        /* paranoid */ verify( ! __preemption_enabled() );
     
    459459//-----------------------------------------------------------------------------
    460460// Main thread construction
    461 static void ?{}( $coroutine & this, current_stack_info_t * info) with( this ) {
     461static void ?{}( coroutine$ & this, current_stack_info_t * info) with( this ) {
    462462        stack.storage = info->storage;
    463463        with(*stack.storage) {
     
    474474}
    475475
    476 static void ?{}( $thread & this, current_stack_info_t * info) with( this ) {
     476static void ?{}( thread$ & this, current_stack_info_t * info) with( this ) {
    477477        ticket = TICKET_RUNNING;
    478478        state = Start;
     
    506506}
    507507
    508 static void init(processor & this, const char name[], cluster & _cltr, $thread * initT) with( this ) {
     508static void init(processor & this, const char name[], cluster & _cltr, thread$ * initT) with( this ) {
    509509        this.name = name;
    510510        this.cltr = &_cltr;
     
    545545}
    546546
    547 void ?{}(processor & this, const char name[], cluster & _cltr, $thread * initT) {
     547void ?{}(processor & this, const char name[], cluster & _cltr, thread$ * initT) {
    548548        ( this.terminated ){};
    549549        ( this.runner ){};
     
    663663}
    664664
    665 void doregister( cluster * cltr, $thread & thrd ) {
     665void doregister( cluster * cltr, thread$ & thrd ) {
    666666        lock      (cltr->thread_list_lock __cfaabi_dbg_ctx2);
    667667        cltr->nthreads += 1;
     
    670670}
    671671
    672 void unregister( cluster * cltr, $thread & thrd ) {
     672void unregister( cluster * cltr, thread$ & thrd ) {
    673673        lock  (cltr->thread_list_lock __cfaabi_dbg_ctx2);
    674674        remove(cltr->threads, thrd );
Note: See TracChangeset for help on using the changeset viewer.