Changeset 50b8885


Ignore:
Timestamp:
Feb 13, 2020, 4:40:16 PM (22 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
b0c7419
Parents:
3381ed7
Message:

Removed owner reason from monitors which was only for debug and did not prove very helpful

Files:
4 edited

Legend:

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

    r3381ed7 r50b8885  
    9494        enum coroutine_state { Halted, Start, Primed, Inactive, Active, Rerun, Reschedule };
    9595        enum __Preemption_Reason { __NO_PREEMPTION, __ALARM_PREEMPTION, __POLL_PREEMPTION };
    96         enum __Owner_Reason { __NO_OWNER, __ENTER_FREE, __ENTER_ACCEPT, __ENTER_DTOR_FREE, __ENTER_DTOR_ACCEPT, __ENTER_SIGNAL_BLOCK, __WAITFOR, __LEAVE, __LEAVE_THREAD, __WAIT };
    9796
    9897        struct coroutine_desc {
     
    135134                // current owner of the monitor
    136135                struct thread_desc * owner;
    137 
    138                 enum __Owner_Reason owner_reason;
    139136
    140137                // queue of threads that are blocked waiting for the monitor
  • libcfa/src/concurrency/monitor.cfa

    r3381ed7 r50b8885  
    2727//-----------------------------------------------------------------------------
    2828// Forward declarations
    29 static inline void set_owner ( monitor_desc * this, thread_desc * owner, enum __Owner_Reason );
    30 static inline void set_owner ( monitor_desc * storage [], __lock_size_t count, thread_desc * owner, enum __Owner_Reason );
     29static inline void set_owner ( monitor_desc * this, thread_desc * owner );
     30static inline void set_owner ( monitor_desc * storage [], __lock_size_t count, thread_desc * owner );
    3131static inline void set_mask  ( monitor_desc * storage [], __lock_size_t count, const __waitfor_mask_t & mask );
    3232static inline void reset_mask( monitor_desc * this );
    3333
    34 static inline thread_desc * next_thread( monitor_desc * this, enum __Owner_Reason );
     34static inline thread_desc * next_thread( monitor_desc * this );
    3535static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & monitors );
    3636
     
    9494                if( !this->owner ) {
    9595                        // No one has the monitor, just take it
    96                         set_owner( this, thrd, __ENTER_FREE );
     96                        set_owner( this, thrd );
    9797
    9898                        __cfaabi_dbg_print_safe( "Kernel :  mon is free \n" );
     
    106106                else if( is_accepted( this, group) ) {
    107107                        // Some one was waiting for us, enter
    108                         set_owner( this, thrd, __ENTER_ACCEPT );
     108                        set_owner( this, thrd );
    109109
    110110                        // Reset mask
     
    153153
    154154                        // No one has the monitor, just take it
    155                         set_owner( this, thrd, __ENTER_DTOR_FREE );
     155                        set_owner( this, thrd );
    156156
    157157                        verifyf( kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this );
     
    239239
    240240                // Get the next thread, will be null on low contention monitor
    241                 thread_desc * new_owner = next_thread( this, __LEAVE );
     241                thread_desc * new_owner = next_thread( this );
    242242
    243243                // Check the new owner is consistent with who we wake-up
     
    289289
    290290                // Fetch the next thread, can be null
    291                 thread_desc * new_owner = next_thread( this, __LEAVE_THREAD );
     291                thread_desc * new_owner = next_thread( this );
    292292
    293293                // Release the monitor lock
     
    449449        // Remove any duplicate threads
    450450        for( __lock_size_t i = 0; i < count; i++) {
    451                 thread_desc * new_owner = next_thread( monitors[i], __WAIT );
     451                thread_desc * new_owner = next_thread( monitors[i] );
    452452                insert_unique( threads, thread_count, new_owner );
    453453        }
     
    535535        thread_desc * signallee = pop_head( this.blocked )->waiting_thread;
    536536        /* paranoid */ verify( signallee->next == 0p );
    537         set_owner( monitors, count, signallee, __ENTER_SIGNAL_BLOCK );
     537        set_owner( monitors, count, signallee );
    538538
    539539        __cfaabi_dbg_print_buffer_decl( "Kernel : signal_block condition %p (s: %p)\n", &this, signallee );
     
    641641
    642642                                // Set the owners to be the next thread
    643                                 set_owner( monitors, count, next, __WAITFOR );
     643                                set_owner( monitors, count, next );
    644644
    645645                                // unlock all the monitors
     
    709709// Utilities
    710710
    711 static inline void set_owner( monitor_desc * this, thread_desc * owner, enum __Owner_Reason reason ) {
     711static inline void set_owner( monitor_desc * this, thread_desc * owner ) {
    712712        /* paranoid */ verify( this->lock.lock );
    713713
    714714        //Pass the monitor appropriately
    715715        this->owner = owner;
    716         this->owner_reason = reason;
    717716
    718717        //We are passing the monitor to someone else, which means recursion level is not 0
     
    720719}
    721720
    722 static inline void set_owner( monitor_desc * monitors [], __lock_size_t count, thread_desc * owner, enum __Owner_Reason reason ) {
     721static inline void set_owner( monitor_desc * monitors [], __lock_size_t count, thread_desc * owner ) {
    723722        /* paranoid */ verify ( monitors[0]->lock.lock );
    724723        /* 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] );
    725724        monitors[0]->owner        = owner;
    726         monitors[0]->owner_reason = reason;
    727725        monitors[0]->recursion    = 1;
    728726        for( __lock_size_t i = 1; i < count; i++ ) {
     
    730728                /* paranoid */ verifyf( monitors[i]->owner == kernelTLS.this_thread, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, monitors[i]->owner, monitors[i]->recursion, monitors[i] );
    731729                monitors[i]->owner        = owner;
    732                 monitors[i]->owner_reason = reason;
    733730                monitors[i]->recursion    = 0;
    734731        }
     
    747744}
    748745
    749 static inline thread_desc * next_thread( monitor_desc * this, enum __Owner_Reason reason ) {
     746static inline thread_desc * next_thread( monitor_desc * this ) {
    750747        //Check the signaller stack
    751748        __cfaabi_dbg_print_safe( "Kernel :  mon %p AS-stack top %p\n", this, this->signal_stack.top);
     
    756753                //we need to set the monitor as in use
    757754                /* 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 );
    758                 set_owner( this,  urgent->owner->waiting_thread, reason );
     755                set_owner( this,  urgent->owner->waiting_thread );
    759756
    760757                return check_condition( urgent );
     
    766763        /* 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 );
    767764        /* paranoid */ verify( !new_owner || new_owner->next == 0p );
    768         set_owner( this, new_owner, reason );
     765        set_owner( this, new_owner );
    769766
    770767        return new_owner;
  • libcfa/src/concurrency/monitor.hfa

    r3381ed7 r50b8885  
    3232        signal_stack{};
    3333        owner         = 0p;
    34         owner_reason  = __NO_OWNER;
    3534        recursion     = 0;
    3635        mask.accepted = 0p;
  • tests/concurrent/park/force_preempt.cfa

    r3381ed7 r50b8885  
    2121
    2222void park_loop(Waiter & this, int id, bool force) {
     23
    2324        for(int i = 0; i < 5; i++) {
    2425                // Unpark this thread, don't force a yield
Note: See TracChangeset for help on using the changeset viewer.