Changeset 7b1f6d4


Ignore:
Timestamp:
Dec 21, 2020, 1:55:24 PM (9 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
3d19ae6, d411769c
Parents:
5d369c7 (diff), 276a94d7 (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

Files:
3 added
5 edited
5 moved

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/locks.cfa

    r5d369c7 r7b1f6d4  
    1717                this.t = t;
    1818                this.lock = 0p;
    19                 this.listed = false;
    2019        }
    2120
     
    2524                this.info = info;
    2625                this.lock = 0p;
    27                 this.listed = false;
    2826        }
    2927
     
    3634        info_thread(L) *& Next( info_thread(L) * this ) {
    3735                return (info_thread(L) *)Next( (Colable *)this );
    38         }
    39 
    40         bool listed( info_thread(L) * this ) {
    41                 return Next( (Colable *)this ) != 0p;
    4236        }
    4337}
     
    194188        // This condition_variable member is called from the kernel, and therefore, cannot block, but it can spin.
    195189            lock( cond->lock __cfaabi_dbg_ctx2 );
    196            
    197             if ( i->listed ) {                  // is thread on queue
     190            if ( listed(i) ) {                  // is thread on queue
     191                i->signalled = false;
    198192                cond->last_thread = i;          // REMOVE THIS AFTER DEBUG
    199193                        remove( cond->blocked_threads, *i );             //remove this thread O(1)
     
    227221        void process_popped( condition_variable(L) & this, info_thread(L) & popped ) with( this ) {
    228222                if(&popped != 0p) {
    229                         popped.listed = false;
     223                        popped.signalled = true;
    230224                        count--;
    231225                        if (popped.lock) {
     
    266260                addTail( blocked_threads, *i );
    267261                count++;
    268                 i->listed = true;
    269262                size_t recursion_count = 0;
    270263                if (i->lock) {
     
    308301        }
    309302       
    310         void wait( condition_variable(L) & this, Duration duration ) with(this) {
     303        bool wait( condition_variable(L) & this, Duration duration ) with(this) {
    311304                info_thread( L ) i = { active_thread() };
    312305                queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    313         }
    314 
    315         void wait( condition_variable(L) & this, uintptr_t info, Duration duration ) with(this) {
     306                return i.signalled;
     307        }
     308
     309        bool wait( condition_variable(L) & this, uintptr_t info, Duration duration ) with(this) {
    316310                info_thread( L ) i = { active_thread(), info };
    317311                queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    318         }
    319 
    320         void wait( condition_variable(L) & this, Time time ) with(this) {
     312                return i.signalled;
     313        }
     314
     315        bool wait( condition_variable(L) & this, Time time ) with(this) {
    321316                info_thread( L ) i = { active_thread() };
    322317                queue_info_thread_timeout(this, i, time);
    323         }
    324 
    325         void wait( condition_variable(L) & this, uintptr_t info, Time time ) with(this) {
     318                return i.signalled;
     319        }
     320
     321        bool wait( condition_variable(L) & this, uintptr_t info, Time time ) with(this) {
    326322                info_thread( L ) i = { active_thread(), info };
    327323                queue_info_thread_timeout(this, i, time);
     324                return i.signalled;
    328325        }
    329326
     
    340337        }
    341338       
    342         void wait( condition_variable(L) & this, L & l, Duration duration ) with(this) {
     339        bool wait( condition_variable(L) & this, L & l, Duration duration ) with(this) {
    343340                info_thread(L) i = { active_thread() };
    344341                i.lock = &l;
    345342                queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    346         }
    347        
    348         void wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) {
     343                return i.signalled;
     344        }
     345       
     346        bool wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) {
    349347                info_thread(L) i = { active_thread(), info };
    350348                i.lock = &l;
    351349                queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    352         }
    353        
    354         void wait( condition_variable(L) & this, L & l, Time time ) with(this) {
     350                return i.signalled;
     351        }
     352       
     353        bool wait( condition_variable(L) & this, L & l, Time time ) with(this) {
    355354                info_thread(L) i = { active_thread() };
    356355                i.lock = &l;
    357356                queue_info_thread_timeout(this, i, time );
    358         }
    359        
    360         void wait( condition_variable(L) & this, L & l, uintptr_t info, Time time ) with(this) {
     357                return i.signalled;
     358        }
     359       
     360        bool wait( condition_variable(L) & this, L & l, uintptr_t info, Time time ) with(this) {
    361361                info_thread(L) i = { active_thread(), info };
    362362                i.lock = &l;
    363363                queue_info_thread_timeout(this, i, time );
    364         }
    365 }
     364                return i.signalled;
     365        }
     366}
  • libcfa/src/concurrency/locks.hfa

    r5d369c7 r7b1f6d4  
    3636                uintptr_t info;
    3737                L * lock;
    38                 bool listed;                                    // true if info_thread is on queue, false otherwise;
     38                bool signalled;                                 // true when signalled and false when timeout wakes thread
    3939        };
    4040
     
    4646        info_thread(L) *& Back( info_thread(L) * this );
    4747        info_thread(L) *& Next( info_thread(L) * this );
    48         bool listed( info_thread(L) * this );
    4948}
    5049
     
    5251//// Blocking Locks
    5352///////////////////////////////////////////////////////////////////
    54 
    55 // struct lock_thread {
    56 //      struct $thread * t;
    57 //      lock_thread * next;
    58 // };
    59 
    60 // void ?{}( lock_thread & this, struct $thread * thd );
    61 // void ^?{}( lock_thread & this );
    62 
    63 // lock_thread *& get_next( lock_thread & );
    6453
    6554struct blocking_lock {
     
    183172        int counter( condition_variable(L) & this );
    184173
    185         // TODO: look into changing timout routines to return bool showing if signalled or woken by kernel
    186174        void wait( condition_variable(L) & this );
    187175        void wait( condition_variable(L) & this, uintptr_t info );
    188         void wait( condition_variable(L) & this, Duration duration );
    189         void wait( condition_variable(L) & this, uintptr_t info, Duration duration );
    190         void wait( condition_variable(L) & this, Time time );
    191         void wait( condition_variable(L) & this, uintptr_t info, Time time );
     176        bool wait( condition_variable(L) & this, Duration duration );
     177        bool wait( condition_variable(L) & this, uintptr_t info, Duration duration );
     178        bool wait( condition_variable(L) & this, Time time );
     179        bool wait( condition_variable(L) & this, uintptr_t info, Time time );
    192180
    193181        void wait( condition_variable(L) & this, L & l );
    194182        void wait( condition_variable(L) & this, L & l, uintptr_t info );
    195         void wait( condition_variable(L) & this, L & l, Duration duration );
    196         void wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration );
    197         void wait( condition_variable(L) & this, L & l, Time time );
    198         void wait( condition_variable(L) & this, L & l, uintptr_t info, Time time );
     183        bool wait( condition_variable(L) & this, L & l, Duration duration );
     184        bool wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration );
     185        bool wait( condition_variable(L) & this, L & l, Time time );
     186        bool wait( condition_variable(L) & this, L & l, uintptr_t info, Time time );
    199187}
  • tests/.expect/queue.txt

    r5d369c7 r7b1f6d4  
    11empty
     20
     318
    240 2 4 6 8 10 12 14 16 18
    3518
    4 18 1 3 5 7 9 11 13 15 17 19
     618
     718 1 3 5 7 9 11 13 15 17
     80 1 2 3 4 5 6 7 8 9
     96 7 8 9
     100 1 2 3 4 5
     116 7 8 9 0 1 2 3 4 5
    512empty
    6130 0 2 2 4 4 6 6 8 8 10 10 12 12 14 14 16 16 18 18
  • tests/.expect/sequence.txt

    r5d369c7 r7b1f6d4  
    4418 1 3 5 7 9 11 13 15 17 19
    5518 1
     60 1 2 3 4 5 6 7 8 9
     79
     89 8 7 6 5 4 3 1 -2 0
     94 3 1 -2 0
     109 8 7 6 5
     114 3 1 -2 0 9 8 7 6 5
    612empty
    7130 0 2 2 4 4 6 6 8 8 10 10 12 12 14 14 16 16 18 18
  • tests/.expect/stack.txt

    r5d369c7 r7b1f6d4  
    11empty
    2218 16 14 12 10 8 6 4 2 0
     318
    340
    4519 17 15 13 11 9 7 5 3 1 0
  • tests/collections/queue.cfa

    r5d369c7 r7b1f6d4  
    3333        }
    3434
     35        sout | head(fred).i | nl;
     36        sout | tail(fred).i | nl;
     37
    3538        for ( QueueIter(Fred) iter = { fred }; iter >> f; ) {
    3639                sout | f.i | ' ';
     
    5053                add( fred, *new( 2 * i + 1 ) );
    5154        }
     55
     56        Fred * front = new( -1 );
     57        addHead( fred, *front );
     58        sout | succ( fred, front )->i | nl;
     59        remove( fred, *front );
     60        delete( front );
     61
     62        Fred & end = dropTail( fred );
     63        delete( &end );
     64
    5265        for ( over( fredIter, fred ); fredIter >> f; ) {
    5366                sout | f.i | ' ';
     
    5669
    5770        for ( over( fredIter, fred ); fredIter >> f; ) {
     71                delete( &f );
     72        }
     73
     74        Queue(Fred) fred0;
     75        Fred * middle;
     76        for ( i; 10 ) {
     77                if( i == 5) {
     78                        middle = new( i );
     79                        add( fred0, *middle );
     80                        continue;
     81                }
     82                add( fred0, *new( i ) );
     83        }
     84
     85        for ( QueueIter(Fred) iter = { fred0 }; iter >> f; ) {
     86                sout | f.i | ' ';
     87        }
     88        sout | nl;
     89
     90        Queue(Fred) fred2;
     91
     92        split( fred2, fred0, *middle);
     93
     94        for ( over( fredIter, fred0 ); fredIter >> f; ) {
     95                sout | f.i | ' ';
     96        }
     97        sout | nl;
     98
     99        for ( over( fredIter, fred2 ); fredIter >> f; ) {
     100                sout | f.i | ' ';
     101        }
     102        sout | nl;
     103
     104        transfer( fred0, fred2);
     105
     106        for ( over( fredIter, fred0 ); fredIter >> f; ) {
     107                sout | f.i | ' ';
     108        }
     109        sout | nl;
     110
     111        for ( over( fredIter, fred0 ); fredIter >> f; ) {
    58112                delete( &f );
    59113        }
  • tests/collections/sequence.cfa

    r5d369c7 r7b1f6d4  
    6969
    7070        for ( over( fredIter, fred ); fredIter >> f; ) {
     71                delete( &f );
     72        }
     73
     74        Sequence(Fred) fred0;
     75        Fred * middle;
     76        for ( i; 10 ) {
     77                if( i == 5) {
     78                        middle = new( i );
     79                        addHead( fred0, *middle );
     80                        continue;
     81                }
     82                addHead( fred0, *new( i ) );
     83        }
     84
     85        for ( SeqIterRev(Fred) iter = { fred0 }; iter >> f; ) {
     86                sout | f.i | ' ';
     87        }
     88        sout | nl;
     89
     90        Fred * front = new( -1 );
     91        insertBef( fred0, *front, tail(fred0));
     92        insertAft( fred0, *front, *new( -2 ) );
     93        remove( fred0, *front );
     94        delete( front );
     95
     96        sout | head(fred0).i | nl;
     97        Fred & end = dropTail( fred );
     98        delete( &end );
     99
     100        for ( over( fredIter, fred0 ); fredIter >> f; ) {
     101                sout | f.i | ' ';
     102        }
     103        sout | nl;
     104
     105        Sequence(Fred) fred2;
     106
     107        split( fred2, fred0, *middle);
     108
     109        for ( over( fredIter, fred0 ); fredIter >> f; ) {
     110                sout | f.i | ' ';
     111        }
     112        sout | nl;
     113
     114        for ( over( fredIter, fred2 ); fredIter >> f; ) {
     115                sout | f.i | ' ';
     116        }
     117        sout | nl;
     118
     119        transfer( fred0, fred2);
     120
     121        for ( over( fredIter, fred0 ); fredIter >> f; ) {
     122                sout | f.i | ' ';
     123        }
     124        sout | nl;
     125
     126        for ( over( fredIter, fred0 ); fredIter >> f; ) {
    71127                delete( &f );
    72128        }
  • tests/collections/stack.cfa

    r5d369c7 r7b1f6d4  
    3737        }
    3838        sout | nl;
     39
     40        sout | head(fred).i | nl;
    3941       
    4042        for ( i; 9 ) {
  • tests/unified_locking/locks.cfa

    r5d369c7 r7b1f6d4  
    11#include <stdio.h>
    22#include "locks.hfa"
    3 
    4 #include "kernel_private.hfa"
    5 #include <stdlib.h>
    6 
    7 #include <kernel.hfa>
    83#include <stdlib.hfa>
    94#include <thread.hfa>
     
    224219int main() {
    225220        processor p[2];
     221        wait( c_s, 1`ns );
    226222        printf("Start Test 1: multi acquisition lock and condition variable single wait/notify\n");
    227223        {
Note: See TracChangeset for help on using the changeset viewer.