Changes in / [7b1f6d4:5d369c7]


Ignore:
Files:
5 added
8 deleted
5 edited

Legend:

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

    r7b1f6d4 r5d369c7  
    1717                this.t = t;
    1818                this.lock = 0p;
     19                this.listed = false;
    1920        }
    2021
     
    2425                this.info = info;
    2526                this.lock = 0p;
     27                this.listed = false;
    2628        }
    2729
     
    3436        info_thread(L) *& Next( info_thread(L) * this ) {
    3537                return (info_thread(L) *)Next( (Colable *)this );
     38        }
     39
     40        bool listed( info_thread(L) * this ) {
     41                return Next( (Colable *)this ) != 0p;
    3642        }
    3743}
     
    188194        // This condition_variable member is called from the kernel, and therefore, cannot block, but it can spin.
    189195            lock( cond->lock __cfaabi_dbg_ctx2 );
    190             if ( listed(i) ) {                  // is thread on queue
    191                 i->signalled = false;
     196           
     197            if ( i->listed ) {                  // is thread on queue
    192198                cond->last_thread = i;          // REMOVE THIS AFTER DEBUG
    193199                        remove( cond->blocked_threads, *i );             //remove this thread O(1)
     
    221227        void process_popped( condition_variable(L) & this, info_thread(L) & popped ) with( this ) {
    222228                if(&popped != 0p) {
    223                         popped.signalled = true;
     229                        popped.listed = false;
    224230                        count--;
    225231                        if (popped.lock) {
     
    260266                addTail( blocked_threads, *i );
    261267                count++;
     268                i->listed = true;
    262269                size_t recursion_count = 0;
    263270                if (i->lock) {
     
    301308        }
    302309       
    303         bool wait( condition_variable(L) & this, Duration duration ) with(this) {
     310        void wait( condition_variable(L) & this, Duration duration ) with(this) {
    304311                info_thread( L ) i = { active_thread() };
    305312                queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    306                 return i.signalled;
    307         }
    308 
    309         bool wait( condition_variable(L) & this, uintptr_t info, Duration duration ) with(this) {
     313        }
     314
     315        void wait( condition_variable(L) & this, uintptr_t info, Duration duration ) with(this) {
    310316                info_thread( L ) i = { active_thread(), info };
    311317                queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    312                 return i.signalled;
    313         }
    314 
    315         bool wait( condition_variable(L) & this, Time time ) with(this) {
     318        }
     319
     320        void wait( condition_variable(L) & this, Time time ) with(this) {
    316321                info_thread( L ) i = { active_thread() };
    317322                queue_info_thread_timeout(this, i, time);
    318                 return i.signalled;
    319         }
    320 
    321         bool wait( condition_variable(L) & this, uintptr_t info, Time time ) with(this) {
     323        }
     324
     325        void wait( condition_variable(L) & this, uintptr_t info, Time time ) with(this) {
    322326                info_thread( L ) i = { active_thread(), info };
    323327                queue_info_thread_timeout(this, i, time);
    324                 return i.signalled;
    325328        }
    326329
     
    337340        }
    338341       
    339         bool wait( condition_variable(L) & this, L & l, Duration duration ) with(this) {
     342        void wait( condition_variable(L) & this, L & l, Duration duration ) with(this) {
    340343                info_thread(L) i = { active_thread() };
    341344                i.lock = &l;
    342345                queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    343                 return i.signalled;
    344         }
    345        
    346         bool wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) {
     346        }
     347       
     348        void wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) {
    347349                info_thread(L) i = { active_thread(), info };
    348350                i.lock = &l;
    349351                queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    350                 return i.signalled;
    351         }
    352        
    353         bool wait( condition_variable(L) & this, L & l, Time time ) with(this) {
     352        }
     353       
     354        void wait( condition_variable(L) & this, L & l, Time time ) with(this) {
    354355                info_thread(L) i = { active_thread() };
    355356                i.lock = &l;
    356357                queue_info_thread_timeout(this, i, time );
    357                 return i.signalled;
    358         }
    359        
    360         bool wait( condition_variable(L) & this, L & l, uintptr_t info, Time time ) with(this) {
     358        }
     359       
     360        void 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                 return i.signalled;
    365         }
    366 }
     364        }
     365}
  • libcfa/src/concurrency/locks.hfa

    r7b1f6d4 r5d369c7  
    3636                uintptr_t info;
    3737                L * lock;
    38                 bool signalled;                                 // true when signalled and false when timeout wakes thread
     38                bool listed;                                    // true if info_thread is on queue, false otherwise;
    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 );
    4849}
    4950
     
    5152//// Blocking Locks
    5253///////////////////////////////////////////////////////////////////
     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 & );
    5364
    5465struct blocking_lock {
     
    172183        int counter( condition_variable(L) & this );
    173184
     185        // TODO: look into changing timout routines to return bool showing if signalled or woken by kernel
    174186        void wait( condition_variable(L) & this );
    175187        void wait( condition_variable(L) & this, uintptr_t info );
    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 );
     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 );
    180192
    181193        void wait( condition_variable(L) & this, L & l );
    182194        void wait( condition_variable(L) & this, L & l, uintptr_t info );
    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 );
     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 );
    187199}
  • tests/.expect/queue.txt

    r7b1f6d4 r5d369c7  
    11empty
    2 0
    3 18
    420 2 4 6 8 10 12 14 16 18
    5318
    6 18
    7 18 1 3 5 7 9 11 13 15 17
    8 0 1 2 3 4 5 6 7 8 9
    9 6 7 8 9
    10 0 1 2 3 4 5
    11 6 7 8 9 0 1 2 3 4 5
     418 1 3 5 7 9 11 13 15 17 19
    125empty
    1360 0 2 2 4 4 6 6 8 8 10 10 12 12 14 14 16 16 18 18
  • tests/.expect/sequence.txt

    r7b1f6d4 r5d369c7  
    4418 1 3 5 7 9 11 13 15 17 19
    5518 1
    6 0 1 2 3 4 5 6 7 8 9
    7 9
    8 9 8 7 6 5 4 3 1 -2 0
    9 4 3 1 -2 0
    10 9 8 7 6 5
    11 4 3 1 -2 0 9 8 7 6 5
    126empty
    1370 0 2 2 4 4 6 6 8 8 10 10 12 12 14 14 16 16 18 18
  • tests/.expect/stack.txt

    r7b1f6d4 r5d369c7  
    11empty
    2218 16 14 12 10 8 6 4 2 0
    3 18
    430
    5419 17 15 13 11 9 7 5 3 1 0
Note: See TracChangeset for help on using the changeset viewer.