Changeset a843067 for src/libcfa


Ignore:
Timestamp:
Sep 21, 2017, 4:39:49 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
dbe7756
Parents:
6ff4507
Message:

Fixed several errors in monitor.c
Update debug prints
Added proper sched-ext-parse test

Location:
src/libcfa/concurrency
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/coroutine.c

    r6ff4507 ra843067  
    123123        if(pageSize == 0ul) pageSize = sysconf( _SC_PAGESIZE );
    124124
    125         LIB_DEBUG_PRINT_SAFE("FRED");
    126 
    127125        size_t cxtSize = libCeiling( sizeof(machine_context_t), 8 ); // minimum alignment
    128126
  • src/libcfa/concurrency/monitor.c

    r6ff4507 ra843067  
    8484extern "C" {
    8585        // Enter single monitor
    86         static void __enter_monitor_desc( const __monitor_group_t & group ) {
    87                 monitor_desc * this = group.list[0];
    88 
     86        static void __enter_monitor_desc( monitor_desc * this, const __monitor_group_t & group ) {
    8987                // Lock the monitor spinlock, lock_yield to reduce contention
    9088                lock_yield( &this->lock DEBUG_CTX2 );
     
    137135                lock_yield( &this->lock DEBUG_CTX2 );
    138136
    139                 verifyf( this_thread == this->owner, "Expected owner to be %p, got %p (r: %i)", this_thread, this->owner, this->recursion );
     137                LIB_DEBUG_PRINT_SAFE("Kernel : %10p Leaving mon %p (%p)\n", this_thread, this, this->owner);
     138
     139                verifyf( this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", this_thread, this->owner, this->recursion, this );
    140140
    141141                // Leaving a recursion level, decrement the counter
     
    172172                thrd->self_cor.state = Halted;
    173173
    174                 verifyf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i)", thrd, this->owner, this->recursion );
     174                verifyf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", thrd, this->owner, this->recursion, this );
    175175
    176176                // Leaving a recursion level, decrement the counter
     
    197197static inline void enter( __monitor_group_t monitors ) {
    198198        for(int i = 0; i < monitors.size; i++) {
    199                 __enter_monitor_desc( monitors );
     199                __enter_monitor_desc( monitors.list[i], monitors );
    200200        }
    201201}
     
    229229        this_thread->monitors.func = func;
    230230
     231        LIB_DEBUG_PRINT_SAFE("MGUARD : enter %d\n", count);
     232
    231233        // Enter the monitors in order
    232234        __monitor_group_t group = {this.m, this.count, func};
    233235        enter( group );
     236
     237        LIB_DEBUG_PRINT_SAFE("MGUARD : entered\n");
    234238}
    235239
     
    237241// Dtor for monitor guard
    238242void ^?{}( monitor_guard_t & this ) {
     243        LIB_DEBUG_PRINT_SAFE("MGUARD : leaving %d\n", this.count);
     244
    239245        // Leave the monitors in order
    240246        leave( this.m, this.count );
     247
     248        LIB_DEBUG_PRINT_SAFE("MGUARD : left\n");
    241249
    242250        // Restore thread context
     
    299307        }
    300308
     309        // Save monitor states
     310        monitor_save;
     311
    301312        // Remove any duplicate threads
    302313        for( int i = 0; i < count; i++) {
     
    305316        }
    306317
    307         blockAndWake( threads, thread_count );
     318        // Everything is ready to go to sleep
     319        BlockInternal( locks, count, threads, thread_count );
     320
     321        // We are back, restore the owners and recursions
     322        monitor_restore;
    308323}
    309324
     
    458473
    459474static inline void set_owner( monitor_desc * this, thread_desc * owner ) {
     475        LIB_DEBUG_PRINT_SAFE("Kernal :   Setting owner of %p to %p ( was %p)\n", this, owner, this->owner );
     476
    460477        //Pass the monitor appropriately
    461478        this->owner = owner;
     
    502519
    503520        // Check if there are any acceptable functions
    504         if( !it ) return -1;
     521        if( !it ) return false;
    505522
    506523        // If this isn't the first monitor to test this, there is no reason to repeat the test.
Note: See TracChangeset for help on using the changeset viewer.