Ignore:
File:
1 edited

Legend:

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

    r2026bb6 rae66348  
    1111// Author           : Thierry Delisle
    1212// Created On       : Fri May 25 01:37:11 2018
    13 // Last Modified By : Thierry Delisle
    14 // Last Modified On : Fri May 25 01:37:51 2018
    15 // Update Count     : 0
     13// Last Modified By : Peter A. Buhr
     14// Last Modified On : Wed Dec  4 09:16:39 2019
     15// Update Count     : 1
    1616//
    1717
     
    4040        if( is_locked ) {
    4141                append( blocked_threads, kernelTLS.this_thread );
    42                 BlockInternal( &lock );
     42                unlock( lock );
     43                park( __cfaabi_dbg_ctx );
    4344        }
    4445        else {
     
    6263        lock( this.lock __cfaabi_dbg_ctx2 );
    6364        this.is_locked = (this.blocked_threads != 0);
    64         WakeThread(
    65                 pop_head( this.blocked_threads )
     65        unpark(
     66                pop_head( this.blocked_threads ) __cfaabi_dbg_ctx2
    6667        );
    6768        unlock( this.lock );
     
    7374        this.lock{};
    7475        this.blocked_threads{};
    75         this.owner = NULL;
     76        this.owner = 0p;
    7677        this.recursion_count = 0;
    7778}
     
    8384void lock(recursive_mutex_lock & this) with(this) {
    8485        lock( lock __cfaabi_dbg_ctx2 );
    85         if( owner == NULL ) {
     86        if( owner == 0p ) {
    8687                owner = kernelTLS.this_thread;
    8788                recursion_count = 1;
     
    9495        else {
    9596                append( blocked_threads, kernelTLS.this_thread );
    96                 BlockInternal( &lock );
     97                unlock( lock );
     98                park( __cfaabi_dbg_ctx );
    9799        }
    98100}
     
    101103        bool ret = false;
    102104        lock( lock __cfaabi_dbg_ctx2 );
    103         if( owner == NULL ) {
     105        if( owner == 0p ) {
    104106                owner = kernelTLS.this_thread;
    105107                recursion_count = 1;
     
    118120        recursion_count--;
    119121        if( recursion_count == 0 ) {
    120                 thread_desc * thrd = pop_head( blocked_threads );
     122                $thread * thrd = pop_head( blocked_threads );
    121123                owner = thrd;
    122124                recursion_count = (thrd ? 1 : 0);
    123                 WakeThread( thrd );
     125                unpark( thrd __cfaabi_dbg_ctx2 );
    124126        }
    125127        unlock( lock );
     
    138140void notify_one(condition_variable & this) with(this) {
    139141        lock( lock __cfaabi_dbg_ctx2 );
    140         WakeThread(
    141                 pop_head( this.blocked_threads )
     142        unpark(
     143                pop_head( this.blocked_threads ) __cfaabi_dbg_ctx2
    142144        );
    143145        unlock( lock );
     
    147149        lock( lock __cfaabi_dbg_ctx2 );
    148150        while(this.blocked_threads) {
    149                 WakeThread(
    150                         pop_head( this.blocked_threads )
     151                unpark(
     152                        pop_head( this.blocked_threads ) __cfaabi_dbg_ctx2
    151153                );
    152154        }
     
    157159        lock( this.lock __cfaabi_dbg_ctx2 );
    158160        append( this.blocked_threads, kernelTLS.this_thread );
    159         BlockInternal( &this.lock );
     161        unlock( this.lock );
     162        park( __cfaabi_dbg_ctx );
    160163}
    161164
     
    164167        lock( this.lock __cfaabi_dbg_ctx2 );
    165168        append( this.blocked_threads, kernelTLS.this_thread );
    166         void __unlock(void) {
    167                 unlock(l);
    168                 unlock(this.lock);
    169         }
    170         BlockInternal( __unlock );
     169        unlock(l);
     170        unlock(this.lock);
     171        park( __cfaabi_dbg_ctx );
    171172        lock(l);
    172173}
Note: See TracChangeset for help on using the changeset viewer.