Ignore:
Timestamp:
Jul 30, 2020, 3:00:19 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
920dca3
Parents:
e0f93e0
Message:

Re-worked IO to use epoll and support multiple io_contexts per cluster.
Also redid how cluster options are handled.
Changed how iofwd calls are passed to support future features and io_contexts rework.

File:
1 edited

Legend:

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

    re0f93e0 rf00b26d4  
    130130KERNEL_STORAGE($thread,              mainThread);
    131131KERNEL_STORAGE(__stack_t,            mainThreadCtx);
     132KERNEL_STORAGE(io_context,           mainPollerThread);
    132133KERNEL_STORAGE(__scheduler_RWLock_t, __scheduler_lock);
    133134#if !defined(__CFA_NO_STATISTICS__)
     
    310311}
    311312
    312 void ?{}(cluster & this, const char name[], Duration preemption_rate, unsigned io_flags) with( this ) {
     313void ?{}(cluster & this, const char name[], Duration preemption_rate, unsigned num_io, const io_context_params & io_params) with( this ) {
    313314        this.name = name;
    314315        this.preemption_rate = preemption_rate;
     
    335336        ready_mutate_unlock( last_size );
    336337
    337 
    338         __kernel_io_startup( this, io_flags, &this == mainCluster );
     338        this.io.cnt  = num_io;
     339        this.io.ctxs = aalloc(num_io);
     340        for(i; this.io.cnt) {
     341                (this.io.ctxs[i]){ this, io_params };
     342        }
    339343}
    340344
    341345void ^?{}(cluster & this) {
    342         __kernel_io_shutdown( this, &this == mainCluster );
     346        for(i; this.io.cnt) {
     347                ^(this.io.ctxs[i]){ true };
     348        }
     349        free(this.io.ctxs);
    343350
    344351        // Lock the RWlock so no-one pushes/pops while we are changing the queue
     
    853860        // Initialize the main cluster
    854861        mainCluster = (cluster *)&storage_mainCluster;
    855         (*mainCluster){"Main Cluster"};
     862        (*mainCluster){"Main Cluster", 0};
    856863
    857864        __cfadbg_print_safe(runtime_core, "Kernel : Main cluster ready\n");
     
    901908        #endif
    902909
     910        // Start IO
     911        __kernel_io_startup();
     912
    903913        // Enable preemption
    904914        kernel_start_preemption();
     
    918928
    919929        // Now that the system is up, finish creating systems that need threading
    920         __kernel_io_finish_start( *mainCluster );
    921 
     930        mainCluster->io.ctxs = (io_context *)&storage_mainPollerThread;
     931        mainCluster->io.cnt  = 1;
     932        (*mainCluster->io.ctxs){ *mainCluster };
    922933
    923934        __cfadbg_print_safe(runtime_core, "Kernel : Started\n--------------------------------------------------\n\n");
     
    930941static void __kernel_shutdown(void) {
    931942        //Before we start shutting things down, wait for systems that need threading to shutdown
    932         __kernel_io_prepare_stop( *mainCluster );
     943        ^(*mainCluster->io.ctxs){};
     944        mainCluster->io.cnt  = 0;
     945        mainCluster->io.ctxs = 0p;
    933946
    934947        /* paranoid */ verify( TL_GET( preemption_state.enabled ) );
     
    949962        // Disable preemption
    950963        kernel_stop_preemption();
     964
     965        // Stop IO
     966        __kernel_io_shutdown();
    951967
    952968        // Destroy the main processor and its context in reverse order of construction
Note: See TracChangeset for help on using the changeset viewer.