Changeset 447bf833 for src


Ignore:
Timestamp:
May 24, 2017, 4:16:20 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
a8e64c4, cf0b892
Parents:
7f623d6f (diff), 8bcaf21 (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:/u/cforall/software/cfa/cfa-cc

Location:
src
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/monitor

    r7f623d6f r447bf833  
    8787void wait( condition * this );
    8888void signal( condition * this );
     89void signal_block( condition * this );
    8990#endif //MONITOR_H
  • src/libcfa/concurrency/monitor.c

    r7f623d6f r447bf833  
    6262                        //Some one else has the monitor, wait in line for it
    6363                        append( &this->entry_queue, thrd );
     64                        LIB_DEBUG_PRINT_SAFE("%p Blocking on entry\n", thrd);
    6465                        ScheduleInternal( &this->lock );
    6566
     
    9798                unlock( &this->lock );
    9899
     100                LIB_DEBUG_PRINT_SAFE("Next owner is %p\n", new_owner);
     101
    99102                //We need to wake-up the thread
    100103                ScheduleThread( new_owner );
     
    149152        assertf( this->monitors != NULL, "Waiting with no monitors (%p)", this->monitors );
    150153        assertf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );
     154        assertf( this->monitor_count < 32u, "Excessive monitor count (%i)", this->monitor_count );
    151155
    152156        unsigned short count = this->monitor_count;
     
    184188        }
    185189
    186         debug_break();
    187 
    188190        for( int i = 0; i < count; i++) {
    189191                thread_desc * new_owner = next_thread( this->monitors[i] );
     
    191193        }
    192194
    193         debug_break();
    194 
    195195        LIB_DEBUG_PRINT_SAFE("Will unblock: ");
    196196        for(int i = 0; i < thread_count; i++) {
     
    202202        ScheduleInternal( locks, count, threads, thread_count );
    203203
    204 
     204        debug_break();
    205205        //WE WOKE UP
    206206
     
    224224        unsigned short count = this->monitor_count;
    225225       
     226        //Some more checking in debug
    226227        LIB_DEBUG_DO(
    227228                thread_desc * this_thrd = this_thread();
     
    237238        );
    238239
     240        //Lock all the monitors
    239241        lock_all( this->monitors, NULL, count );
    240242        LIB_DEBUG_PRINT_SAFE("Signalling");
    241243
     244        //Pop the head of the waiting queue
    242245        __condition_node_t * node = pop_head( &this->blocked );
     246
     247        //Add the thread to the proper AS stack
    243248        for(int i = 0; i < count; i++) {
    244249                __condition_criterion_t * crit = &node->criteria[i];
     
    250255        LIB_DEBUG_PRINT_SAFE("\n");
    251256
     257        //Release
    252258        unlock_all( this->monitors, count );
     259}
     260
     261void signal_block( condition * this ) {
     262        if( !this->blocked.head ) {
     263                LIB_DEBUG_PRINT_SAFE("Nothing to signal\n");
     264                return;
     265        }
     266
     267        //Check that everything is as expected
     268        assertf( this->monitors != NULL, "Waiting with no monitors (%p)", this->monitors );
     269        assertf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );
     270
     271        unsigned short count = this->monitor_count;
     272        unsigned int recursions[ count ];               //Save the current recursion levels to restore them later
     273        spinlock *   locks     [ count ];               //We need to pass-in an array of locks to ScheduleInternal
     274
     275        lock_all( this->monitors, locks, count );
     276
     277        //create creteria
     278        __condition_node_t waiter;
     279        waiter.waiting_thread = this_thread();
     280        waiter.count = count;
     281        waiter.next = NULL;
     282
     283        __condition_criterion_t criteria[count];
     284        for(int i = 0; i < count; i++) {
     285                LIB_DEBUG_PRINT_SAFE( "Criterion %p\n", &criteria[i] );
     286                criteria[i].ready  = false;
     287                criteria[i].owner  = &waiter;
     288                criteria[i].next   = NULL;
     289                criteria[i].target = this->monitors[i];
     290                push( &criteria[i].target->signal_stack, &criteria[i] );
     291        }
     292
     293        waiter.criteria = criteria;
     294
     295        //save contexts
     296        save_recursion( this->monitors, recursions, count );
     297
     298        //Find the thread to run
     299        thread_desc * signallee = pop_head( &this->blocked )->waiting_thread;
     300        for(int i = 0; i < count; i++) {
     301                set_owner( this->monitors[i], signallee );
     302        }
     303
     304        LIB_DEBUG_PRINT_SAFE( "Waiting on signal block\n" );
     305        debug_break();
     306
     307        //Everything is ready to go to sleep
     308        ScheduleInternal( locks, count, &signallee, 1 );
     309
     310        debug_break();
     311        LIB_DEBUG_PRINT_SAFE( "Back from signal block\n" );
     312
     313        //We are back, restore the owners and recursions
     314        lock_all( locks, count );
     315        restore_recursion( this->monitors, recursions, count );
     316        unlock_all( locks, count );
    253317}
    254318
     
    335399
    336400        for(    int i = 0; i < count; i++ ) {
     401
    337402                LIB_DEBUG_PRINT_SAFE( "Checking %p for %p\n", &criteria[i], target );
    338403                if( &criteria[i] == target ) {
  • src/libcfa/concurrency/thread

    r7f623d6f r447bf833  
    8282
    8383void yield();
     84void yield( unsigned times );
    8485
    8586#endif //THREADS_H
  • src/libcfa/concurrency/thread.c

    r7f623d6f r447bf833  
    8787}
    8888
     89void yield( unsigned times ) {
     90        for( unsigned i = 0; i < times; i++ ) {
     91                yield();
     92        }
     93}
     94
    8995void ThreadCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
    9096        // set state of current coroutine to inactive
  • src/libcfa/gmp

    r7f623d6f r447bf833  
    1010// Created On       : Tue Apr 19 08:43:43 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 14 23:47:36 2017
    13 // Update Count     : 9
     12// Last Modified On : Mon May 22 08:32:39 2017
     13// Update Count     : 13
    1414//
    1515
     
    3535Int ?=?( Int * lhs, long int rhs ) { mpz_set_si( lhs->mpz, rhs ); return *lhs; }
    3636Int ?=?( Int * lhs, unsigned long int rhs ) { mpz_set_ui( lhs->mpz, rhs ); return *lhs; }
    37 //Int ?=?( Int * lhs, const char * rhs ) { if ( mpq_set_str( lhs->mpz, rhs, 0 ) ) abort(); return *lhs; }
     37Int ?=?( Int * lhs, const char * rhs ) { if ( mpz_set_str( lhs->mpz, rhs, 0 ) ) { printf( "invalid string conversion\n" ); abort(); } return *lhs; }
    3838
    3939char ?=?( char * lhs, Int rhs ) { char val = mpz_get_si( rhs.mpz ); *lhs = val; return val; }
  • src/tests/.expect/64/gmp.txt

    r7f623d6f r447bf833  
    44conversions
    55y:97
     6y:12345678901234567890123456789
    67y:3
    78y:-3
     
    2425z:150000000000000000000
    2526z:16666666666666666666
     2716666666666666666666, 2 16666666666666666666, 2
    2628x:16666666666666666666 y:2
    2729
  • src/tests/Makefile.am

    r7f623d6f r447bf833  
    2222concurrent=yes
    2323quick_test+= coroutine thread monitor
    24 concurrent_test=coroutine thread monitor multi-monitor sched-int-disjoint sched-int-barge sched-int-wait sched-ext sched-ext-multi preempt
     24concurrent_test=coroutine thread monitor multi-monitor sched-int-barge sched-int-block sched-int-disjoint sched-int-wait sched-ext sched-ext-multi preempt
    2525else
    2626concurrent=no
  • src/tests/Makefile.in

    r7f623d6f r447bf833  
    230230@BUILD_CONCURRENCY_TRUE@concurrent = yes
    231231@BUILD_CONCURRENCY_FALSE@concurrent_test =
    232 @BUILD_CONCURRENCY_TRUE@concurrent_test = coroutine thread monitor multi-monitor sched-int-disjoint sched-int-barge sched-int-wait sched-ext sched-ext-multi preempt
     232@BUILD_CONCURRENCY_TRUE@concurrent_test = coroutine thread monitor multi-monitor sched-int-barge sched-int-block sched-int-disjoint sched-int-wait sched-ext sched-ext-multi preempt
    233233
    234234# applies to both programs
  • src/tests/gmp.c

    r7f623d6f r447bf833  
    1010// Created On       : Tue Apr 19 08:55:51 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 14 14:46:50 2017
    13 // Update Count     : 530
     12// Last Modified On : Mon May 22 09:05:09 2017
     13// Update Count     : 538
    1414//
    1515
    1616#include <gmp>
    1717
    18 int main() {
     18int main( void ) {
    1919        sout | "constructors" | endl;
    2020        short int si = 3;
     
    2525        sout | "conversions" | endl;
    2626        y = 'a';
     27        sout | "y:" | y | endl;
     28        y = "12345678901234567890123456789";
    2729        sout | "y:" | y | endl;
    2830        y = si;
     
    6264        z = x / 3;
    6365        sout | "z:" | z | endl;
     66        sout | div( x, 3 ) | x / 3 | "," | x % 3 | endl;
    6467        [ x, y ] = div( x, 3 );
    6568        sout | "x:" | x | "y:" | y | endl;
    66 //      sout | div( x, 3 ) | x / 3 | "," | x % 3 | endl;
    6769
    6870        sout | endl;
     
    7274        fn = (Int){0}; fn1 = fn;                                                        // 1st case
    7375        sout | (int)0 | fn | endl;
    74         fn = (Int){1}; fn2 = fn1; fn1 = fn;                                     // 2nd case
     76        fn = 1; fn2 = fn1; fn1 = fn;                                            // 2nd case
    7577        sout | 1 | fn | endl;
    76         for ( int i = 2; i <= 200; i += 1 ) {
     78        for ( unsigned int i = 2; i <= 200; i += 1 ) {
    7779                fn = fn1 + fn2; fn2 = fn1; fn1 = fn;                    // general case
    7880                sout | i | fn | endl;
     
    8385        sout | "Factorial Numbers" | endl;
    8486        Int fact;
    85         fact = (Int){1};                                                                        // 1st case
     87        fact = 1;                                                                                       // 1st case
    8688        sout | (int)0 | fact | endl;
    87         for ( int i = 1; i <= 40; i += 1 ) {
     89        for ( unsigned int i = 1; i <= 40; i += 1 ) {
    8890                fact = fact * i;                                                                // general case
    8991                sout | i | fact | endl;
Note: See TracChangeset for help on using the changeset viewer.