Ignore:
Timestamp:
Jun 16, 2017, 4:45:20 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
ec35498
Parents:
70c2df8
Message:

Preemption with some bug fixes and much more debugging, still not working at 100%

File:
1 edited

Legend:

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

    r70c2df8 r4e6fb8e  
    8989}
    9090
     91LIB_DEBUG_DO( bool validate( alarm_list_t * this ) {
     92        alarm_node_t ** it = &this->head;
     93        while( (*it) ) {
     94                it = &(*it)->next;
     95        }
     96
     97        return it == this->tail;
     98})
     99
    91100static inline void insert_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t p ) {
    92101        assert( !n->next );
     
    98107        }
    99108        *p = n;
     109
     110        LIB_DEBUG_DO( assert( validate( this ) ) );
    100111}
    101112
     
    107118
    108119        insert_at( this, n, it );
     120
     121        LIB_DEBUG_DO( assert( validate( this ) ) );
    109122}
    110123
     
    118131                head->next = NULL;
    119132        }
     133        LIB_DEBUG_DO( assert( validate( this ) ) );
    120134        return head;
    121135}
     
    123137static inline void remove_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t it ) {
    124138        assert( it );
    125         assert( (*it)->next == n );
    126 
    127         (*it)->next = n->next;
     139        assert( (*it) == n );
     140
     141        (*it) = n->next;
    128142        if( !n-> next ) {
    129143                this->tail = it;
    130144        }
    131145        n->next = NULL;
     146
     147        LIB_DEBUG_DO( assert( validate( this ) ) );
    132148}
    133149
    134150static inline void remove( alarm_list_t * this, alarm_node_t * n ) {
    135151        alarm_node_t ** it = &this->head;
    136         while( (*it) && (*it)->next != n ) {
     152        while( (*it) && (*it) != n ) {
    137153                it = &(*it)->next;
    138154        }
    139155
     156        LIB_DEBUG_DO( assert( validate( this ) ) );
     157
    140158        if( *it ) { remove_at( this, n, it ); }
     159
     160        LIB_DEBUG_DO( assert( validate( this ) ) );
    141161}
    142162
     
    145165        assert( !systemProcessor->pending_alarm );
    146166        lock( &systemProcessor->alarm_lock );
     167        LIB_DEBUG_DO( assert( validate( &systemProcessor->alarms ) ) );
    147168        {
    148169                bool first = !systemProcessor->alarms.head;
     
    158179        unlock( &systemProcessor->alarm_lock );
    159180        this->set = true;
    160         enable_interrupts();
     181        enable_interrupts( __PRETTY_FUNCTION__ );
    161182}
    162183
    163184void unregister_self( alarm_node_t * this ) {
     185        LIB_DEBUG_DO(
     186                char text[256];
     187                __attribute__((unused)) int len = snprintf( text, 256, "Kernel : unregister %p start\n", this );
     188                LIB_DEBUG_WRITE( STDERR_FILENO, text, len );
     189        );
    164190        disable_interrupts();
    165191        lock( &systemProcessor->alarm_lock );
     192        LIB_DEBUG_DO( assert( validate( &systemProcessor->alarms ) ) );
    166193        remove( &systemProcessor->alarms, this );
    167194        unlock( &systemProcessor->alarm_lock );
    168195        disable_interrupts();
    169196        this->set = false;
    170 }
     197        LIB_DEBUG_DO(
     198                len = snprintf( text, 256, "Kernel : unregister %p end\n", this );
     199                LIB_DEBUG_WRITE( STDERR_FILENO, text, len );
     200        );
     201}
Note: See TracChangeset for help on using the changeset viewer.