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

File:
1 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;
Note: See TracChangeset for help on using the changeset viewer.