Changeset e9c0b4c


Ignore:
Timestamp:
Apr 24, 2021, 9:05:30 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
adaee12
Parents:
28d426a
Message:

I/O drain now keeps the schedlock for the duration of the call.
(Rather than locking/unlocking for each thread).

Location:
libcfa/src/concurrency
Files:
2 edited

Legend:

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

    r28d426a re9c0b4c  
    4040        #include "kernel.hfa"
    4141        #include "kernel/fwd.hfa"
     42        #include "kernel_private.hfa"
    4243        #include "io/types.hfa"
    4344
     
    8990        static inline unsigned __flush( struct $io_context & );
    9091        static inline __u32 __release_sqes( struct $io_context & );
     92        extern void __kernel_unpark( $thread * thrd );
    9193
    9294        bool __cfa_io_drain( processor * proc ) {
    9395                /* paranoid */ verify( ! __preemption_enabled() );
     96                /* paranoid */ verify( ready_schedule_islocked() );
    9497                /* paranoid */ verify( proc );
    9598                /* paranoid */ verify( proc->io.ctx );
     
    115118                        __cfadbg_print_safe( io, "Kernel I/O : Syscall completed : cqe %p, result %d for %p\n", &cqe, cqe.res, future );
    116119
    117                         fulfil( *future, cqe.res );
     120                        __kernel_unpark( fulfil( *future, cqe.res, false ) );
    118121                }
    119122
     
    124127                __atomic_store_n( ctx->cq.head, head + count, __ATOMIC_SEQ_CST );
    125128
     129                /* paranoid */ verify( ready_schedule_islocked() );
    126130                /* paranoid */ verify( ! __preemption_enabled() );
    127131
  • libcfa/src/concurrency/kernel.cfa

    r28d426a re9c0b4c  
    551551// Scheduler routines
    552552// KERNEL ONLY
    553 void __schedule_thread( $thread * thrd ) {
     553static void __schedule_thread( $thread * thrd ) {
    554554        /* paranoid */ verify( ! __preemption_enabled() );
    555555        /* paranoid */ verify( kernelTLS().this_proc_id );
     
    659659}
    660660
     661void __kernel_unpark( $thread * thrd ) {
     662        /* paranoid */ verify( ! __preemption_enabled() );
     663        /* paranoid */ verify( ready_schedule_islocked());
     664
     665        if( !thrd ) return;
     666
     667        if(__must_unpark(thrd)) {
     668                // Wake lost the race,
     669                __schedule_thread( thrd );
     670        }
     671
     672        /* paranoid */ verify( ready_schedule_islocked());
     673        /* paranoid */ verify( ! __preemption_enabled() );
     674}
     675
    661676void unpark( $thread * thrd ) {
    662677        if( !thrd ) return;
     
    871886
    872887static inline bool __maybe_io_drain( processor * proc ) {
     888        bool ret = false;
    873889        #if defined(CFA_HAVE_LINUX_IO_URING_H)
    874890                __cfadbg_print_safe(runtime_core, "Kernel : core %p checking io for ring %d\n", proc, proc->io.ctx->fd);
     
    879895                unsigned tail = *ctx->cq.tail;
    880896                if(head == tail) return false;
    881                 return __cfa_io_drain( proc );
     897                ret = __cfa_io_drain( proc );
    882898        #endif
     899        return ret;
    883900}
    884901
Note: See TracChangeset for help on using the changeset viewer.