Changeset f00b26d4 for libcfa/src/concurrency/kernel.cfa
- Timestamp:
- Jul 30, 2020, 3:00:19 PM (4 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
re0f93e0 rf00b26d4 130 130 KERNEL_STORAGE($thread, mainThread); 131 131 KERNEL_STORAGE(__stack_t, mainThreadCtx); 132 KERNEL_STORAGE(io_context, mainPollerThread); 132 133 KERNEL_STORAGE(__scheduler_RWLock_t, __scheduler_lock); 133 134 #if !defined(__CFA_NO_STATISTICS__) … … 310 311 } 311 312 312 void ?{}(cluster & this, const char name[], Duration preemption_rate, unsigned io_flags) with( this ) {313 void ?{}(cluster & this, const char name[], Duration preemption_rate, unsigned num_io, const io_context_params & io_params) with( this ) { 313 314 this.name = name; 314 315 this.preemption_rate = preemption_rate; … … 335 336 ready_mutate_unlock( last_size ); 336 337 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 } 339 343 } 340 344 341 345 void ^?{}(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); 343 350 344 351 // Lock the RWlock so no-one pushes/pops while we are changing the queue … … 853 860 // Initialize the main cluster 854 861 mainCluster = (cluster *)&storage_mainCluster; 855 (*mainCluster){"Main Cluster" };862 (*mainCluster){"Main Cluster", 0}; 856 863 857 864 __cfadbg_print_safe(runtime_core, "Kernel : Main cluster ready\n"); … … 901 908 #endif 902 909 910 // Start IO 911 __kernel_io_startup(); 912 903 913 // Enable preemption 904 914 kernel_start_preemption(); … … 918 928 919 929 // 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 }; 922 933 923 934 __cfadbg_print_safe(runtime_core, "Kernel : Started\n--------------------------------------------------\n\n"); … … 930 941 static void __kernel_shutdown(void) { 931 942 //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; 933 946 934 947 /* paranoid */ verify( TL_GET( preemption_state.enabled ) ); … … 949 962 // Disable preemption 950 963 kernel_stop_preemption(); 964 965 // Stop IO 966 __kernel_io_shutdown(); 951 967 952 968 // Destroy the main processor and its context in reverse order of construction
Note: See TracChangeset
for help on using the changeset viewer.