Ignore:
Timestamp:
May 10, 2017, 5:00:47 PM (9 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, stuck-waitfor-destruct, with_gc
Children:
8514fe19, dbfb35d
Parents:
0f9bef3 (diff), 29cf9c8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/libcfa/concurrency
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/monitor

    r0f9bef3 r6250a312  
    8181}
    8282
     83static inline void ^?{}( condition * this ) {
     84        free( this->monitors );
     85}
     86
    8387void wait( condition * this );
    8488void signal( condition * this );
  • src/libcfa/concurrency/monitor.c

    r0f9bef3 r6250a312  
    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        }
  • src/libcfa/concurrency/thread.c

    r0f9bef3 r6250a312  
    4040        this->next = NULL;
    4141
    42         this->current_monitors      = NULL;
    43         this->current_monitor_count = 0;
     42        this->current_monitors      = &this->mon;
     43        this->current_monitor_count = 1;
    4444}
    4545
Note: See TracChangeset for help on using the changeset viewer.