Ignore:
File:
1 edited

Legend:

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

    r9c59cd4 ra933dcf4  
    1717#include "monitor"
    1818
     19#include <stdlib>
     20
    1921#include "kernel_private.h"
    2022#include "libhdr.h"
     
    130132        this_thread()->current_monitors      = this->prev_mntrs;
    131133        this_thread()->current_monitor_count = this->prev_count;
     134}
     135
     136void debug_break() __attribute__(( noinline ))
     137{
     138       
    132139}
    133140
     
    171178
    172179        //Find the next thread(s) to run
    173         unsigned short thread_count = count;
     180        unsigned short thread_count = 0;
    174181        thread_desc * threads[ count ];
     182        for(int i = 0; i < count; i++) {
     183                threads[i] = 0;
     184        }
     185
     186        debug_break();
    175187
    176188        for( int i = 0; i < count; i++) {
    177189                thread_desc * new_owner = next_thread( this->monitors[i] );
    178                 thread_count = insert_unique( threads, i, new_owner );
    179         }
     190                thread_count = insert_unique( threads, thread_count, new_owner );
     191        }
     192
     193        debug_break();
    180194
    181195        LIB_DEBUG_PRINT_SAFE("Will unblock: ");
     
    339353                LIB_DEBUG_PRINT_SAFE("Branding\n");
    340354                assertf( thrd->current_monitors != NULL, "No current monitor to brand condition", thrd->current_monitors );
    341                 this->monitors = thrd->current_monitors;
    342355                this->monitor_count = thrd->current_monitor_count;
     356
     357                this->monitors = malloc( this->monitor_count * sizeof( *this->monitors ) );
     358                for( int i = 0; i < this->monitor_count; i++ ) {
     359                        this->monitors[i] = thrd->current_monitors[i];
     360                }
    343361        }
    344362}
    345363
    346364static inline unsigned short insert_unique( thread_desc ** thrds, unsigned short end, thread_desc * val ) {
    347         for(int i = 0; i < end; i++) {
     365        if( !val ) return end;
     366
     367        for(int i = 0; i <= end; i++) {
    348368                if( thrds[i] == val ) return end;
    349369        }
Note: See TracChangeset for help on using the changeset viewer.