Changeset 1756e08 for libcfa/src


Ignore:
Timestamp:
Sep 29, 2022, 11:33:03 AM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master
Children:
5f9c42b
Parents:
a659b31
Message:

Added some defensive programming to work around parsing bug

Location:
libcfa/src/concurrency
Files:
7 edited

Legend:

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

    ra659b31 r1756e08  
    5555        this.period  = period;
    5656        this.thrd = thrd;
    57         this.timeval = __kernel_get_time() + alarm;
     57        this.deadline = __kernel_get_time() + alarm;
    5858        set = false;
    5959        type = User;
     
    6464        this.period  = period;
    6565        this.proc = proc;
    66         this.timeval = __kernel_get_time() + alarm;
     66        this.deadline = __kernel_get_time() + alarm;
    6767        set = false;
    6868        type = Kernel;
     
    7272        this.initial = alarm;
    7373        this.period  = period;
    74         this.timeval = __kernel_get_time() + alarm;
     74        this.deadline = __kernel_get_time() + alarm;
    7575        set = false;
    7676        type = Callback;
     
    8585void insert( alarm_list_t * this, alarm_node_t * n ) {
    8686        alarm_node_t * it = & (*this)`first;
    87         while( it && (n->timeval > it->timeval) ) {
     87        while( it && (n->deadline > it->deadline) ) {
    8888                it = & (*it)`next;
    8989        }
     
    116116
    117117                Time curr = __kernel_get_time();
    118                 __cfadbg_print_safe( preemption, " KERNEL: alarm inserting %p (%lu -> %lu).\n", this, curr.tn, this->timeval.tn );
     118                __cfadbg_print_safe( preemption, " KERNEL: alarm inserting %p (%lu -> %lu).\n", this, curr.tn, this->deadline.tn );
    119119                insert( &alarms, this );
    120                 __kernel_set_timer( this->timeval - curr);
     120                __kernel_set_timer( this->deadline - curr);
    121121                this->set = true;
    122122        }
  • libcfa/src/concurrency/alarm.hfa

    ra659b31 r1756e08  
    5757        };
    5858
    59         Time timeval;           // actual time at which the alarm goes off
     59        Time deadline;          // actual time at which the alarm goes off
    6060        enum alarm_type type;   // true if this is not a user defined alarm
    6161        bool set                :1;     // whether or not the alarm has be registered
  • libcfa/src/concurrency/io.cfa

    ra659b31 r1756e08  
    206206        }
    207207
    208         bool __cfa_io_drain( processor * proc ) {
     208        bool __cfa_io_drain( struct processor * proc ) {
    209209                bool local = false;
    210210                bool remote = false;
     
    273273        }
    274274
    275         bool __cfa_io_flush( processor * proc ) {
     275        bool __cfa_io_flush( struct processor * proc ) {
    276276                /* paranoid */ verify( ! __preemption_enabled() );
    277277                /* paranoid */ verify( proc );
     
    353353
    354354                disable_interrupts();
    355                 processor * proc = __cfaabi_tls.this_processor;
     355                struct processor * proc = __cfaabi_tls.this_processor;
    356356                io_context$ * ctx = proc->io.ctx;
    357357                /* paranoid */ verify( __cfaabi_tls.this_processor );
     
    433433                disable_interrupts();
    434434                __STATS__( true, if(!lazy) io.submit.eagr += 1; )
    435                 processor * proc = __cfaabi_tls.this_processor;
     435                struct processor * proc = __cfaabi_tls.this_processor;
    436436                io_context$ * ctx = proc->io.ctx;
    437437                /* paranoid */ verify( __cfaabi_tls.this_processor );
     
    641641
    642642        #if defined(CFA_WITH_IO_URING_IDLE)
    643                 bool __kernel_read(processor * proc, io_future_t & future, iovec & iov, int fd) {
     643                bool __kernel_read(struct processor * proc, io_future_t & future, iovec & iov, int fd) {
    644644                        io_context$ * ctx = proc->io.ctx;
    645645                        /* paranoid */ verify( ! __preemption_enabled() );
     
    692692                }
    693693
    694                 void __cfa_io_idle( processor * proc ) {
     694                void __cfa_io_idle( struct processor * proc ) {
    695695                        iovec iov;
    696696                        __atomic_acquire( &proc->io.ctx->cq.lock );
  • libcfa/src/concurrency/io/types.hfa

    ra659b31 r1756e08  
    127127        struct __attribute__((aligned(64))) io_context$ {
    128128                io_arbiter$ * arbiter;
    129                 processor * proc;
     129                struct processor * proc;
    130130
    131131                __outstanding_io_queue ext_sq;
  • libcfa/src/concurrency/kernel/cluster.cfa

    ra659b31 r1756e08  
    254254}
    255255
    256 static void assign_list(unsigned & valrq, unsigned & valio, dlist(processor) & list, unsigned count) {
    257         processor * it = &list`first;
     256static void assign_list(unsigned & valrq, unsigned & valio, dlist(struct processor) & list, unsigned count) {
     257        struct processor * it = &list`first;
    258258        for(unsigned i = 0; i < count; i++) {
    259259                /* paranoid */ verifyf( it, "Unexpected null iterator, at index %u of %u\n", i, count);
     
    278278
    279279#if defined(CFA_HAVE_LINUX_IO_URING_H)
    280         static void assign_io(io_context$ ** data, size_t count, dlist(processor) & list) {
    281                 processor * it = &list`first;
     280        static void assign_io(io_context$ ** data, size_t count, dlist(struct processor) & list) {
     281                struct processor * it = &list`first;
    282282                while(it) {
    283283                        /* paranoid */ verifyf( it, "Unexpected null iterator\n");
  • libcfa/src/concurrency/preemption.cfa

    ra659b31 r1756e08  
    104104static inline alarm_node_t * get_expired( alarm_list_t * alarms, Time currtime ) {
    105105        if( ! & (*alarms)`first ) return 0p;                                            // If no alarms return null
    106         if( (*alarms)`first.timeval >= currtime ) return 0p;    // If alarms head not expired return null
     106        if( (*alarms)`first.deadline >= currtime ) return 0p;   // If alarms head not expired return null
    107107        return pop(alarms);                                                                     // Otherwise just pop head
    108108}
     
    140140                if( period > 0 ) {
    141141                        __cfadbg_print_buffer_local( preemption, " KERNEL: alarm period is %lu.\n", period`ns );
    142                         node->timeval = currtime + period;  // Alarm is periodic, add currtime to it (used cached current time)
     142                        node->deadline = currtime + period;  // Alarm is periodic, add currtime to it (used cached current time)
    143143                        insert( alarms, node );             // Reinsert the node for the next time it triggers
    144144                }
     
    147147        // If there are still alarms pending, reset the timer
    148148        if( & (*alarms)`first ) {
    149                 Duration delta = (*alarms)`first.timeval - currtime;
     149                Duration delta = (*alarms)`first.deadline - currtime;
    150150                __kernel_set_timer( delta );
    151151        }
  • libcfa/src/concurrency/ready_queue.cfa

    ra659b31 r1756e08  
    6262//-----------------------------------------------------------------------
    6363__attribute__((hot)) void push(struct cluster * cltr, struct thread$ * thrd, unpark_hint hint) with (cltr->sched) {
    64         processor * const proc = kernelTLS().this_processor;
     64        struct processor * const proc = kernelTLS().this_processor;
    6565        const bool external = (!proc) || (cltr != proc->cltr);
    6666        const bool remote   = hint == UNPARK_REMOTE;
     
    116116        /* paranoid */ verify( kernelTLS().this_processor->rdq.id < lanes_count );
    117117
    118         processor * const proc = kernelTLS().this_processor;
     118        struct processor * const proc = kernelTLS().this_processor;
    119119        unsigned this = proc->rdq.id;
    120120        /* paranoid */ verify( this < lanes_count );
Note: See TracChangeset for help on using the changeset viewer.