Ignore:
Timestamp:
Feb 19, 2021, 1:47:09 PM (3 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:
4f762d3
Parents:
b44959f
Message:

New implementation of io based on instance burrowing.
Trying to avoid the unbounded growth of the previous flat combining approach.

File:
1 edited

Legend:

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

    rb44959f r78da4ab  
    104104KERNEL_STORAGE($thread,              mainThread);
    105105KERNEL_STORAGE(__stack_t,            mainThreadCtx);
    106 KERNEL_STORAGE(io_context,           mainPollerThread);
     106KERNEL_STORAGE(io_context,           mainIoContext);
    107107KERNEL_STORAGE(__scheduler_RWLock_t, __scheduler_lock);
    108108#if !defined(__CFA_NO_STATISTICS__)
     
    231231        __kernel_io_startup();
    232232
     233        io_context * mainio = (io_context *)&storage_mainIoContext;
     234        (*mainio){ *mainCluster };
     235
    233236        // Add the main thread to the ready queue
    234237        // once resume is called on mainProcessor->runner the mainThread needs to be scheduled like any normal thread
     
    243246        // THE SYSTEM IS NOW COMPLETELY RUNNING
    244247
    245 
    246         // SKULLDUGGERY: The constructor for the mainCluster will call alloc with a dimension of 0
    247         // malloc *can* return a non-null value, we should free it if that is the case
    248         free( mainCluster->io.ctxs );
    249 
    250         // Now that the system is up, finish creating systems that need threading
    251         mainCluster->io.ctxs = (io_context *)&storage_mainPollerThread;
    252         mainCluster->io.cnt  = 1;
    253         (*mainCluster->io.ctxs){ *mainCluster };
    254 
    255248        __cfadbg_print_safe(runtime_core, "Kernel : Started\n--------------------------------------------------\n\n");
    256249
     
    263256static void __kernel_shutdown(void) {
    264257        //Before we start shutting things down, wait for systems that need threading to shutdown
    265         ^(*mainCluster->io.ctxs){};
    266         mainCluster->io.cnt  = 0;
    267         mainCluster->io.ctxs = 0p;
     258        io_context * mainio = (io_context *)&storage_mainIoContext;
     259        ^(*mainio){};
    268260
    269261        /* paranoid */ verify( __preemption_enabled() );
     
    486478        pending_preemption = false;
    487479
     480        this.io.ctx = 0p;
     481        this.io.lock = false;
     482
    488483        #if !defined(__CFA_NO_STATISTICS__)
    489484                print_stats = 0;
     
    584579        threads{ __get };
    585580
     581        io.arbiter = create();
     582        io.params = io_params;
     583
    586584        doregister(this);
    587585
     
    596594        ready_mutate_unlock( last_size );
    597595        enable_interrupts_noPoll(); // Don't poll, could be in main cluster
    598 
    599 
    600         this.io.cnt  = num_io;
    601         this.io.ctxs = aalloc(num_io);
    602         for(i; this.io.cnt) {
    603                 (this.io.ctxs[i]){ this, io_params };
    604         }
    605596}
    606597
    607598void ^?{}(cluster & this) {
    608         for(i; this.io.cnt) {
    609                 ^(this.io.ctxs[i]){ true };
    610         }
    611         free(this.io.ctxs);
     599        destroy(this.io.arbiter);
    612600
    613601        // Lock the RWlock so no-one pushes/pops while we are changing the queue
Note: See TracChangeset for help on using the changeset viewer.