Ignore:
Timestamp:
May 17, 2021, 9:29:43 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
c2794b2
Parents:
6312b1c (diff), 1eb222ff (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:
libcfa/src/concurrency
Files:
2 edited

Legend:

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

    r6312b1c r02a43ff  
    5555        this.period  = period;
    5656        this.thrd = thrd;
     57        this.timeval = __kernel_get_time() + alarm;
    5758        set = false;
    5859        type = User;
     
    6364        this.period  = period;
    6465        this.proc = proc;
     66        this.timeval = __kernel_get_time() + alarm;
    6567        set = false;
    6668        type = Kernel;
    6769}
    6870void ?{}( alarm_node_t & this, Alarm_Callback callback, Duration alarm, Duration period ) with( this ) {
     71        this.callback = callback;
    6972        this.initial = alarm;
    7073        this.period  = period;
    71         this.callback = callback;
     74        this.timeval = __kernel_get_time() + alarm;
    7275        set = false;
    7376        type = Callback;
     
    110113        lock( event_kernel->lock __cfaabi_dbg_ctx2 );
    111114        {
    112                 Time curr = __kernel_get_time();
    113                 this->timeval = curr + this->initial;
    114 
    115115                /* paranoid */ verify( validate( alarms ) );
    116116
     117                Time curr = __kernel_get_time();
    117118                __cfadbg_print_safe( preemption, " KERNEL: alarm inserting %p (%lu -> %lu).\n", this, curr.tn, this->timeval.tn );
    118119                insert( &alarms, this );
    119                 __kernel_set_timer( this->initial );
     120                __kernel_set_timer( this->timeval - curr);
    120121                this->set = true;
    121122        }
  • libcfa/src/concurrency/locks.cfa

    r6312b1c r02a43ff  
    188188                alarm_node_t alarm_node;
    189189                condition_variable(L) * cond;
    190                 info_thread(L) * i;
     190                info_thread(L) * info_thd;
    191191        };
    192192
     
    194194                this.alarm_node{ callback, alarm, period };
    195195                this.cond = c;
    196                 this.i = i;
     196                this.info_thd = i;
    197197        }
    198198
     
    206206                //      may still be called after a thread has been removed from the queue but
    207207                //      before the alarm is unregistered
    208                 if ( listed(i) ) {      // is thread on queue
    209                         i->signalled = false;
     208                if ( listed(info_thd) ) {       // is thread on queue
     209                        info_thd->signalled = false;
    210210                        // remove this thread O(1)
    211                         remove( cond->blocked_threads, *i );
     211                        remove( cond->blocked_threads, *info_thd );
    212212                        cond->count--;
    213                         if( i->lock ) {
     213                        if( info_thd->lock ) {
    214214                                // call lock's on_notify if a lock was passed
    215                                 on_notify(*i->lock, i->t);
     215                                on_notify(*info_thd->lock, info_thd->t);
    216216                        } else {
    217217                                // otherwise wake thread
    218                                 unpark( i->t );
     218                                unpark( info_thd->t );
    219219                        }
    220220                }
Note: See TracChangeset for help on using the changeset viewer.