Changeset 059ad16 for libcfa


Ignore:
Timestamp:
Nov 19, 2021, 3:53:47 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
7ef162b2
Parents:
cd4c605
Message:

Flush now supports blocking until at least one I/O op terminates.

Location:
libcfa/src/concurrency
Files:
4 edited

Legend:

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

    rcd4c605 r059ad16  
    133133        }
    134134
    135         void __cfa_io_flush( processor * proc ) {
     135        bool __cfa_io_flush( processor * proc, bool wait ) {
    136136                /* paranoid */ verify( ! __preemption_enabled() );
    137137                /* paranoid */ verify( proc );
     
    141141                $io_context & ctx = *proc->io.ctx;
    142142
    143                 // for(i; 2) {
    144                 //      unsigned idx = proc->rdq.id + i;
    145                 //      cltr->ready_queue.lanes.tscs[idx].tv = -1ull;
    146                 // }
    147 
    148143                __ioarbiter_flush( ctx );
    149144
    150145                __STATS__( true, io.calls.flush++; )
    151                 int ret = syscall( __NR_io_uring_enter, ctx.fd, ctx.sq.to_submit, 0, 0, (sigset_t *)0p, _NSIG / 8);
     146                int ret = syscall( __NR_io_uring_enter, ctx.fd, ctx.sq.to_submit, wait ? 1 : 0, 0, (sigset_t *)0p, _NSIG / 8);
    152147                if( ret < 0 ) {
    153148                        switch((int)errno) {
     
    157152                                // Update statistics
    158153                                __STATS__( false, io.calls.errors.busy ++; )
    159                                 // for(i; 2) {
    160                                 //      unsigned idx = proc->rdq.id + i;
    161                                 //      cltr->ready_queue.lanes.tscs[idx].tv = rdtscl();
    162                                 // }
    163                                 return;
     154                                return false;
    164155                        default:
    165156                                abort( "KERNEL ERROR: IO_URING SYSCALL - (%d) %s\n", (int)errno, strerror(errno) );
     
    183174                ctx.proc->io.pending = false;
    184175
    185                 __cfa_io_drain( proc );
    186                 // for(i; 2) {
    187                 //      unsigned idx = proc->rdq.id + i;
    188                 //      cltr->ready_queue.lanes.tscs[idx].tv = rdtscl();
    189                 // }
     176                return __cfa_io_drain( proc );
    190177        }
    191178
     
    315302                if(sq.to_submit > 30 || !lazy) {
    316303                        ready_schedule_lock();
    317                         __cfa_io_flush( ctx->proc );
     304                        __cfa_io_flush( ctx->proc, false );
    318305                        ready_schedule_unlock();
    319306                }
  • libcfa/src/concurrency/io/setup.cfa

    rcd4c605 r059ad16  
    3232
    3333        void __cfa_io_start( processor * proc ) {}
    34         void __cfa_io_flush( processor * proc ) {}
     34        bool __cfa_io_flush( processor * proc, bool ) {}
    3535        void __cfa_io_stop ( processor * proc ) {}
    3636
  • libcfa/src/concurrency/kernel.cfa

    rcd4c605 r059ad16  
    130130extern void __cfa_io_start( processor * );
    131131extern bool __cfa_io_drain( processor * );
    132 extern void __cfa_io_flush( processor * );
     132extern bool __cfa_io_flush( processor *, bool wait );
    133133extern void __cfa_io_stop ( processor * );
    134134static inline bool __maybe_io_drain( processor * );
     
    197197                        if( !readyThread ) {
    198198                                ready_schedule_lock();
    199                                 __cfa_io_flush( this );
     199                                __cfa_io_flush( this, false );
    200200                                ready_schedule_unlock();
    201201
     
    251251                        if(this->io.pending && !this->io.dirty) {
    252252                                ready_schedule_lock();
    253                                 __cfa_io_flush( this );
     253                                __cfa_io_flush( this, false );
    254254                                ready_schedule_unlock();
    255255                        }
     
    268268
    269269                                // If we can't find a thread, might as well flush any outstanding I/O
    270                                 if(this->io.pending) { __cfa_io_flush( this ); }
     270                                if(this->io.pending) { __cfa_io_flush( this, false ); }
    271271
    272272                                // Spin a little on I/O, just in case
     
    363363
    364364                        if(this->io.pending && !this->io.dirty) {
    365                                 __cfa_io_flush( this );
     365                                __cfa_io_flush( this, false );
    366366                        }
    367367
  • libcfa/src/concurrency/kernel_private.hfa

    rcd4c605 r059ad16  
    3939}
    4040
     41// #define IO_URING_IDLE
     42
    4143//-----------------------------------------------------------------------------
    4244// Scheduler
     
    149151        __atomic_store_n(ll, (bool)false, __ATOMIC_RELEASE);
    150152}
    151 
    152 
    153 
    154 
    155153
    156154//-----------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.