- File:
-
- 1 edited
-
libcfa/src/concurrency/kernel/startup.cfa (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/startup.cfa
r0c3aa67 r7cf3b1d 18 18 19 19 // C Includes 20 #include <errno.h> // errno20 #include <errno.h> // errno 21 21 #include <signal.h> 22 #include <string.h> // strerror23 #include <unistd.h> // sysconf22 #include <string.h> // strerror 23 #include <unistd.h> // sysconf 24 24 25 25 extern "C" { 26 #include <limits.h>// PTHREAD_STACK_MIN27 #include <unistd.h> // syscall28 #include <sys/eventfd.h> // eventfd29 #include <sys/mman.h>// mprotect30 #include <sys/resource.h>// getrlimit26 #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 31 31 } 32 32 33 33 // 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 37 36 #include "limits.hfa" 38 37 #include "math.hfa" … … 98 97 extern void __kernel_alarm_startup(void); 99 98 extern void __kernel_alarm_shutdown(void); 100 extern void __cfa_io_start( processor * );101 extern void __cfa_io_stop ( processor * );102 99 103 100 //----------------------------------------------------------------------------- … … 105 102 extern void __wake_proc(processor *); 106 103 extern int cfa_main_returned; // from interpose.cfa 107 uint32_t __global_random_prime = 4_294_967_291u, __global_random_mask = false;104 extern uint32_t __global_random_seed; 108 105 109 106 //----------------------------------------------------------------------------- … … 114 111 KERNEL_STORAGE(__stack_t, mainThreadCtx); 115 112 KERNEL_STORAGE(__scheduler_RWLock_t, __scheduler_lock); 116 KERNEL_STORAGE(eventfd_t, mainIdleEventFd);117 KERNEL_STORAGE(io_future_t, mainIdleFuture);118 113 #if !defined(__CFA_NO_STATISTICS__) 119 114 KERNEL_STORAGE(__stats_t, mainProcStats); … … 229 224 (*mainProcessor){}; 230 225 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 235 __cfa_io_start( mainProcessor );236 226 register_tls( mainProcessor ); 237 227 … … 315 305 316 306 unregister_tls( mainProcessor ); 317 __cfa_io_stop( mainProcessor );318 307 319 308 // Destroy the main processor and its context in reverse order of construction … … 364 353 proc->local_data = &__cfaabi_tls; 365 354 366 __cfa_io_start( proc );367 355 register_tls( proc ); 368 369 // used for idle sleep when io_uring is present370 io_future_t future;371 eventfd_t idle_buf;372 proc->idle_wctx.ftr = &future;373 proc->idle_wctx.rdbuf = &idle_buf;374 375 356 376 357 // SKULLDUGGERY: We want to create a context for the processor coroutine … … 414 395 415 396 unregister_tls( proc ); 416 __cfa_io_stop( proc );417 397 418 398 return 0p; … … 510 490 preferred = ready_queue_new_preferred(); 511 491 last_proc = 0p; 512 random_state = __global_random_ mask ? __global_random_prime : __global_random_prime ^ rdtscl();492 random_state = __global_random_seed; 513 493 #if defined( __CFA_WITH_VERIFY__ ) 514 494 canary = 0x0D15EA5E0D15EA5Ep; … … 535 515 this.rdq.its = 0; 536 516 this.rdq.itr = 0; 537 this.rdq.id = 0;517 this.rdq.id = MAX; 538 518 this.rdq.target = MAX; 539 519 this.rdq.last = MAX; … … 552 532 this.local_data = 0p; 553 533 554 idle_wctx.evfd = eventfd(0, 0);555 if (idle_ wctx.evfd < 0) {534 this.idle_fd = eventfd(0, 0); 535 if (idle_fd < 0) { 556 536 abort("KERNEL ERROR: PROCESSOR EVENTFD - %s\n", strerror(errno)); 557 537 } 558 538 559 idle_wctx.sem = 0; 560 idle_wctx.wake__time = 0; 539 this.idle_wctx.fd = 0; 561 540 562 541 // I'm assuming these two are reserved for standard input and output 563 542 // so I'm using them as sentinels with idle_wctx. 564 /* paranoid */ verify( idle_wctx.evfd != 0 );565 /* paranoid */ verify( idle_wctx.evfd != 1 );543 /* paranoid */ verify( this.idle_fd != 0 ); 544 /* paranoid */ verify( this.idle_fd != 1 ); 566 545 567 546 #if !defined(__CFA_NO_STATISTICS__) … … 575 554 // Not a ctor, it just preps the destruction but should not destroy members 576 555 static void deinit(processor & this) { 577 close(this.idle_ wctx.evfd);556 close(this.idle_fd); 578 557 } 579 558 … … 626 605 this.name = name; 627 606 this.preemption_rate = preemption_rate; 628 this.sched.readyQ.data = 0p; 629 this.sched.readyQ.tscs = 0p; 630 this.sched.readyQ.count = 0; 631 this.sched.io.tscs = 0p; 632 this.sched.io.data = 0p; 633 this.sched.caches = 0p; 607 ready_queue{}; 634 608 635 609 #if !defined(__CFA_NO_STATISTICS__) … … 670 644 // Unlock the RWlock 671 645 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 680 646 enable_interrupts( false ); // Don't poll, could be in main cluster 681 682 647 683 648 #if !defined(__CFA_NO_STATISTICS__) … … 771 736 check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute 772 737 773 size_t stacksize = max( PTHREAD_STACK_MIN, DEFAULT_STACK_SIZE );738 size_t stacksize = DEFAULT_STACK_SIZE; 774 739 775 740 void * stack;
Note:
See TracChangeset
for help on using the changeset viewer.