Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/ready_subqueue.hfa

    rd3ba775 r353aaba  
    1313
    1414        __thread_desc_link anchor;
     15
     16        #if !defined(__CFA_NO_STATISTICS__)
     17                unsigned cnt;
     18        #endif
    1519};
    1620
     
    2933        this.anchor.next = 0p;
    3034        this.anchor.ts   = 0;
     35        #if !defined(__CFA_NO_STATISTICS__)
     36                this.cnt  = 0;
     37        #endif
    3138
    3239        // We add a boat-load of assertions here because the anchor code is very fragile
     40        /* paranoid */ _Static_assert( offsetof( $thread, link ) == offsetof(__intrusive_lane_t, anchor) );
    3341        /* paranoid */ verify( offsetof( $thread, link ) == offsetof(__intrusive_lane_t, anchor) );
    3442        /* paranoid */ verify( ((uintptr_t)( mock_head(this) ) + offsetof( $thread, link )) == (uintptr_t)(&this.anchor) );
     
    5361// Push a thread onto this lane
    5462// returns true of lane was empty before push, false otherwise
    55 void push( __intrusive_lane_t & this, $thread * node ) {
     63static inline void push( __intrusive_lane_t & this, $thread * node ) {
     64        /* paranoid */ verify( this.lock );
    5665        /* paranoid */ verify( node->link.next == 0p );
    5766        /* paranoid */ verify( node->link.ts   == 0  );
     
    7281        this.prev->link.ts   = rdtscl();
    7382        this.prev = node;
     83        #if !defined(__CFA_NO_STATISTICS__)
     84                this.cnt++;
     85        #endif
    7486}
    7587
     
    7789// returns popped
    7890// returns true of lane was empty before push, false otherwise
    79 $thread * pop( __intrusive_lane_t & this ) {
     91static inline [* $thread, unsigned long long] pop( __intrusive_lane_t & this ) {
     92        /* paranoid */ verify( this.lock );
    8093        /* paranoid */ verify( this.anchor.next != 0p );
    8194        /* paranoid */ verify( this.anchor.ts   != 0  );
    8295
    8396        // Get the relevant nodes locally
     97        unsigned long long ts = this.anchor.ts;
    8498        $thread * node = this.anchor.next;
    8599        this.anchor.next = node->link.next;
     
    88102        node->link.next = 0p;
    89103        node->link.ts   = 0;
     104        #if !defined(__CFA_NO_STATISTICS__)
     105                this.cnt--;
     106        #endif
    90107
    91108        // Update head time stamp
     
    94111        /* paranoid */ verify( node->link.next == 0p );
    95112        /* paranoid */ verify( node->link.ts   == 0  );
    96         return node;
     113        return [node, ts];
    97114}
    98115
     
    107124        return this.anchor.ts;
    108125}
    109 
    110 // Aligned timestamps which are used by the relaxed ready queue
    111 struct __attribute__((aligned(128))) __timestamp_t {
    112         volatile unsigned long long tv;
    113 };
    114 
    115 void  ?{}(__timestamp_t & this) { this.tv = 0; }
    116 void ^?{}(__timestamp_t & this) {}
Note: See TracChangeset for help on using the changeset viewer.