Ignore:
File:
1 edited

Legend:

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

    r22226e4 rc655650  
    1818
    1919// C Includes
    20 #include <errno.h>                                      // errno
     20#include <errno.h>                                                                              // errno
    2121#include <signal.h>
    22 #include <string.h>                                     // strerror
    23 #include <unistd.h>                                     // sysconf
     22#include <string.h>                                                                             // strerror
     23#include <unistd.h>                                                                             // sysconf
    2424
    2525extern "C" {
    26         #include <limits.h>                             // PTHREAD_STACK_MIN
    27         #include <unistd.h>                             // syscall
    28         #include <sys/eventfd.h>                        // eventfd
    29         #include <sys/mman.h>                           // mprotect
    30         #include <sys/resource.h>                       // getrlimit
     26        #include <limits.h>                                                                     // PTHREAD_STACK_MIN
     27        #include <unistd.h>                                                                     // syscall
     28        #include <sys/eventfd.h>                                                        // eventfd
     29        #include <sys/mman.h>                                                           // mprotect
     30        #include <sys/resource.h>                                                       // getrlimit
    3131}
    3232
    3333// CFA Includes
    34 #include "kernel/private.hfa"
    35 #include "iofwd.hfa"
    36 #include "startup.hfa"                                  // STARTUP_PRIORITY_XXX
     34#include "kernel_private.hfa"
     35#include "startup.hfa"                                                                  // STARTUP_PRIORITY_XXX
    3736#include "limits.hfa"
    3837#include "math.hfa"
     
    9897extern void __kernel_alarm_startup(void);
    9998extern void __kernel_alarm_shutdown(void);
    100 extern void __cfa_io_start( processor * );
    101 extern void __cfa_io_stop ( processor * );
    10299
    103100//-----------------------------------------------------------------------------
     
    114111KERNEL_STORAGE(__stack_t,            mainThreadCtx);
    115112KERNEL_STORAGE(__scheduler_RWLock_t, __scheduler_lock);
    116 KERNEL_STORAGE(eventfd_t,            mainIdleEventFd);
    117 KERNEL_STORAGE(io_future_t,          mainIdleFuture);
    118113#if !defined(__CFA_NO_STATISTICS__)
    119114KERNEL_STORAGE(__stats_t, mainProcStats);
     
    229224        (*mainProcessor){};
    230225
    231         mainProcessor->idle_wctx.rdbuf = &storage_mainIdleEventFd;
    232         mainProcessor->idle_wctx.ftr   = (io_future_t*)&storage_mainIdleFuture;
    233         /* paranoid */ verify( sizeof(storage_mainIdleEventFd) == sizeof(eventfd_t) );
    234 
    235226        register_tls( mainProcessor );
    236         __cfa_io_start( mainProcessor );
    237227
    238228        // Start by initializing the main thread
     
    314304        mainProcessor->local_data = 0p;
    315305
    316         __cfa_io_stop( mainProcessor );
    317306        unregister_tls( mainProcessor );
    318307
     
    366355        register_tls( proc );
    367356
    368         __cfa_io_start( proc );
    369 
    370         // used for idle sleep when io_uring is present
    371         io_future_t future;
    372         eventfd_t idle_buf;
    373         proc->idle_wctx.ftr = &future;
    374         proc->idle_wctx.rdbuf = &idle_buf;
    375 
    376 
    377357        // SKULLDUGGERY: We want to create a context for the processor coroutine
    378358        // which is needed for the 2-step context switch. However, there is no reason
     
    401381        // Main routine of the core returned, the core is now fully terminated
    402382        __cfadbg_print_safe(runtime_core, "Kernel : core %p main ended (%p)\n", proc, &proc->runner);
    403 
    404         __cfa_io_stop( proc );
    405383
    406384        #if !defined(__CFA_NO_STATISTICS__)
     
    537515        this.rdq.its = 0;
    538516        this.rdq.itr = 0;
    539         this.rdq.id  = 0;
     517        this.rdq.id  = MAX;
    540518        this.rdq.target = MAX;
    541519        this.rdq.last = MAX;
     
    554532        this.local_data = 0p;
    555533
    556         idle_wctx.evfd = eventfd(0, 0);
    557         if (idle_wctx.evfd < 0) {
     534        this.idle_fd = eventfd(0, 0);
     535        if (idle_fd < 0) {
    558536                abort("KERNEL ERROR: PROCESSOR EVENTFD - %s\n", strerror(errno));
    559537        }
    560538
    561         idle_wctx.sem = 0;
     539        this.idle_wctx.fd = 0;
    562540
    563541        // I'm assuming these two are reserved for standard input and output
    564542        // so I'm using them as sentinels with idle_wctx.
    565         /* paranoid */ verify( idle_wctx.evfd != 0 );
    566         /* paranoid */ verify( idle_wctx.evfd != 1 );
     543        /* paranoid */ verify( this.idle_fd != 0 );
     544        /* paranoid */ verify( this.idle_fd != 1 );
    567545
    568546        #if !defined(__CFA_NO_STATISTICS__)
     
    576554// Not a ctor, it just preps the destruction but should not destroy members
    577555static void deinit(processor & this) {
    578         close(this.idle_wctx.evfd);
     556        close(this.idle_fd);
    579557}
    580558
     
    627605        this.name = name;
    628606        this.preemption_rate = preemption_rate;
    629         this.sched.readyQ.data = 0p;
    630         this.sched.readyQ.tscs = 0p;
    631         this.sched.readyQ.count = 0;
    632         this.sched.io.tscs = 0p;
    633         this.sched.caches = 0p;
     607        ready_queue{};
    634608
    635609        #if !defined(__CFA_NO_STATISTICS__)
     
    670644        // Unlock the RWlock
    671645        ready_mutate_unlock( last_size );
    672 
    673         ready_queue_close( &this );
    674         /* paranoid */ verify( this.sched.readyQ.data == 0p );
    675         /* paranoid */ verify( this.sched.readyQ.tscs == 0p );
    676         /* paranoid */ verify( this.sched.readyQ.count == 0 );
    677         /* paranoid */ verify( this.sched.io.tscs == 0p );
    678         /* paranoid */ verify( this.sched.caches == 0p );
    679 
    680646        enable_interrupts( false ); // Don't poll, could be in main cluster
    681 
    682647
    683648        #if !defined(__CFA_NO_STATISTICS__)
     
    771736        check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
    772737
    773         size_t stacksize = max( PTHREAD_STACK_MIN, DEFAULT_STACK_SIZE );
     738        size_t stacksize = DEFAULT_STACK_SIZE;
    774739
    775740        void * stack;
Note: See TracChangeset for help on using the changeset viewer.