Ignore:
File:
1 edited

Legend:

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

    r70b4aeb9 rd529ad0  
    175175                        /* paranoid */ verify( ! __preemption_enabled() );
    176176
    177                         ctx.proc->io.pending = false;
     177                        __atomic_store_n(&ctx.proc->io.pending, false, __ATOMIC_RELAXED);
    178178                }
    179179
     
    287287        //=============================================================================================
    288288        // submission
    289         static inline void __submit( struct $io_context * ctx, __u32 idxs[], __u32 have, bool lazy) {
     289        static inline void __submit_only( struct $io_context * ctx, __u32 idxs[], __u32 have) {
    290290                // We can proceed to the fast path
    291291                // Get the right objects
     
    304304                sq.to_submit += have;
    305305
    306                 ctx->proc->io.pending = true;
    307                 ctx->proc->io.dirty   = true;
     306                __atomic_store_n(&ctx->proc->io.pending, true, __ATOMIC_RELAXED);
     307                __atomic_store_n(&ctx->proc->io.dirty  , true, __ATOMIC_RELAXED);
     308        }
     309
     310        static inline void __submit( struct $io_context * ctx, __u32 idxs[], __u32 have, bool lazy) {
     311                __sub_ring_t & sq = ctx->sq;
     312                __submit_only(ctx, idxs, have);
     313
    308314                if(sq.to_submit > 30) {
    309315                        __tls_stats()->io.flush.full++;
     
    402408// I/O Arbiter
    403409//=============================================================================================
    404         static inline void block(__outstanding_io_queue & queue, __outstanding_io & item) {
     410        static inline bool enqueue(__outstanding_io_queue & queue, __outstanding_io & item) {
     411                bool was_empty;
     412
    405413                // Lock the list, it's not thread safe
    406414                lock( queue.lock __cfaabi_dbg_ctx2 );
    407415                {
     416                        was_empty = empty(queue.queue);
     417
    408418                        // Add our request to the list
    409419                        add( queue.queue, item );
     
    414424                unlock( queue.lock );
    415425
    416                 wait( item.sem );
     426                return was_empty;
    417427        }
    418428
     
    432442                pa.want = want;
    433443
    434                 block(this.pending, (__outstanding_io&)pa);
     444                enqueue(this.pending, (__outstanding_io&)pa);
     445
     446                wait( pa.sem );
    435447
    436448                return pa.ctx;
     
    485497                ei.lazy = lazy;
    486498
    487                 block(ctx->ext_sq, (__outstanding_io&)ei);
     499                bool we = enqueue(ctx->ext_sq, (__outstanding_io&)ei);
     500
     501                __atomic_store_n(&ctx->proc->io.pending, true, __ATOMIC_SEQ_CST);
     502
     503                if( we ) {
     504                        sigval_t value = { PREEMPT_IO };
     505                        pthread_sigqueue(ctx->proc->kernel_thread, SIGUSR1, value);
     506                }
     507
     508                wait( ei.sem );
    488509
    489510                __cfadbg_print_safe(io, "Kernel I/O : %u submitted from arbiter\n", have);
     
    501522                                        __external_io & ei = (__external_io&)drop( ctx.ext_sq.queue );
    502523
    503                                         __submit(&ctx, ei.idxs, ei.have, ei.lazy);
     524                                        __submit_only(&ctx, ei.idxs, ei.have);
    504525
    505526                                        post( ei.sem );
Note: See TracChangeset for help on using the changeset viewer.