Changeset b1a4300


Ignore:
Timestamp:
May 17, 2018, 3:25:12 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, with_gc
Children:
a83ffa4
Parents:
e9a7e90b
Message:

Added assert for set_timer for duration < 1us && != 0.
Preemption now always calls timer with at least 50us durations.
Fixed verifies in nodebug.

Location:
src/libcfa
Files:
3 edited

Legend:

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

    re9a7e90b rb1a4300  
    3737
    3838void __kernel_set_timer( Duration alarm ) {
     39        verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%luns)", alarm.tv);
    3940        setitimer( ITIMER_REAL, &(itimerval){ alarm }, NULL );
    4041}
     
    6869}
    6970
    70 __cfaabi_dbg_debug_do( bool validate( alarm_list_t * this ) {
     71#if !defined(NDEBUG) && (defined(__CFA_DEBUG__) || defined(__CFA_VERIFY__))
     72bool validate( alarm_list_t * this ) {
    7173        alarm_node_t ** it = &this->head;
    7274        while( (*it) ) {
     
    7577
    7678        return it == this->tail;
    77 })
     79}
     80#endif
    7881
    7982static inline void insert_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t p ) {
  • src/libcfa/concurrency/preemption.c

    re9a7e90b rb1a4300  
    9191        //Loop throught every thing expired
    9292        while( node = get_expired( alarms, currtime ) ) {
     93                // __cfaabi_dbg_print_buffer_decl( " KERNEL: preemption tick.\n" );
    9394
    9495                // Check if this is a kernel
     
    103104                Duration period = node->period;
    104105                if( period > 0 ) {
     106                        // __cfaabi_dbg_print_buffer_local( " KERNEL: alarm period is %lu.\n", period.tv );
    105107                        node->alarm = currtime + period;    // Alarm is periodic, add currtime to it (used cached current time)
    106108                        insert( alarms, node );             // Reinsert the node for the next time it triggers
     
    112114
    113115        // If there are still alarms pending, reset the timer
    114         if( alarms->head ) { __kernel_set_timer( alarms->head->alarm - currtime ); }
     116        if( alarms->head ) {
     117                __cfaabi_dbg_print_buffer_decl( " KERNEL: @%lu(%lu) resetting alarm to %lu.\n", currtime.tv, __kernel_get_time().tv, (alarms->head->alarm - currtime).tv);
     118                Duration delta = alarms->head->alarm - currtime;
     119                Duration caped = max(delta, 50`us);
     120                // itimerval tim  = { caped };
     121                // __cfaabi_dbg_print_buffer_local( "    Values are %lu, %lu, %lu %lu.\n", delta.tv, caped.tv, tim.it_value.tv_sec, tim.it_value.tv_usec);
     122
     123                __kernel_set_timer( caped );
     124        }
    115125}
    116126
     
    335345        if( !preemption_ready() ) { return; }
    336346
    337         __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p).\n", kernelTLS.this_processor, kernelTLS.this_thread );
     347        __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p @ %p).\n", kernelTLS.this_processor, kernelTLS.this_thread, (void *)(cxt->uc_mcontext.CFA_REG_IP) );
    338348
    339349        // Sync flag : prevent recursive calls to the signal handler
     
    377387                                case EAGAIN :
    378388                                case EINTR :
     389                                        {__cfaabi_dbg_print_buffer_decl( " KERNEL: Spurious wakeup %d.\n", err );}
    379390                                        continue;
    380391                        case EINVAL :
  • src/libcfa/time

    re9a7e90b rb1a4300  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // time -- 
    8 // 
     6//
     7// time --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Mar 14 23:18:57 2018
     
    1212// Last Modified On : Sat Apr 14 17:48:23 2018
    1313// Update Count     : 636
    14 // 
     14//
    1515
    1616#pragma once
     
    9191static inline int64_t ?`w( Duration dur ) { return dur.tv / (7LL * 24LL * 60LL * 60LL * TIMEGRAN); }
    9292
     93static inline Duration max( Duration lhs, Duration rhs ) { return  (lhs.tv < rhs.tv) ? rhs : lhs;}
     94static inline Duration min( Duration lhs, Duration rhs ) { return !(rhs.tv < lhs.tv) ? lhs : rhs;}
     95
    9396
    9497//######################### C timeval #########################
Note: See TracChangeset for help on using the changeset viewer.