Changeset 4ecc35a for libcfa


Ignore:
Timestamp:
Mar 21, 2022, 1:28:59 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
dbe2533
Parents:
98d1b90
Message:

Added spin lock to io drain.
last step before completion fairness

Location:
libcfa/src/concurrency
Files:
4 edited

Legend:

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

    r98d1b90 r4ecc35a  
    9393        extern void __kernel_unpark( thread$ * thrd, unpark_hint );
    9494
    95         bool __cfa_io_drain( processor * proc ) {
     95        bool __cfa_io_drain( $io_context * ctx ) {
    9696                /* paranoid */ verify( ! __preemption_enabled() );
    9797                /* paranoid */ verify( ready_schedule_islocked() );
    98                 /* paranoid */ verify( proc );
    99                 /* paranoid */ verify( proc->io.ctx );
     98                /* paranoid */ verify( ctx );
    10099
    101100                // Drain the queue
    102                 $io_context * ctx = proc->io.ctx;
    103101                unsigned head = *ctx->cq.head;
    104102                unsigned tail = *ctx->cq.tail;
     
    110108                if(count == 0) return false;
    111109
     110                if(!__atomic_try_acquire(&ctx->cq.lock)) {
     111                        return false;
     112                }
     113
    112114                for(i; count) {
    113115                        unsigned idx = (head + i) & mask;
     
    130132                /* paranoid */ verify( ready_schedule_islocked() );
    131133                /* paranoid */ verify( ! __preemption_enabled() );
     134
     135                __atomic_unlock(&ctx->cq.lock);
    132136
    133137                return true;
     
    179183
    180184                ready_schedule_lock();
    181                 bool ret = __cfa_io_drain( proc );
     185                bool ret = __cfa_io_drain( &ctx );
    182186                ready_schedule_unlock();
    183187                return ret;
  • libcfa/src/concurrency/io/setup.cfa

    r98d1b90 r4ecc35a  
    214214
    215215                // completion queue
     216                cq.lock      = 0;
    216217                cq.head      = (volatile __u32 *)(((intptr_t)cq.ring_ptr) + params.cq_off.head);
    217218                cq.tail      = (volatile __u32 *)(((intptr_t)cq.ring_ptr) + params.cq_off.tail);
  • libcfa/src/concurrency/io/types.hfa

    r98d1b90 r4ecc35a  
    7878
    7979        struct __cmp_ring_t {
     80                volatile bool lock;
     81
    8082                // Head and tail of the ring
    8183                volatile __u32 * head;
  • libcfa/src/concurrency/kernel.cfa

    r98d1b90 r4ecc35a  
    136136static void mark_awake(__cluster_proc_list & idles, processor & proc);
    137137
    138 extern bool __cfa_io_drain( processor * );
     138extern bool __cfa_io_drain( $io_context * );
    139139extern bool __cfa_io_flush( processor *, int min_comp );
    140140static inline bool __maybe_io_drain( processor * );
     
    839839                if(head == tail) return false;
    840840                ready_schedule_lock();
    841                 ret = __cfa_io_drain( proc );
     841                ret = __cfa_io_drain( ctx );
    842842                ready_schedule_unlock();
    843843        #endif
Note: See TracChangeset for help on using the changeset viewer.