// // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // clib/cfathread.cfa -- // // Author : Thierry Delisle // Created On : Tue Sep 22 15:31:20 2020 // Last Modified By : // Last Modified On : // Update Count : // #include "kernel.hfa" #include "thread.hfa" thread CRunner { void (*themain)( CRunner * ); }; static void ?{}( CRunner & this, void (*themain)( CRunner * ) ) { this.themain = themain; } void main( CRunner & this ) { this.themain( &this ); } processor * procs = 0p; int proc_cnt = 1; extern "C" { //-------------------- // Basic thread management CRunner * cfathread_create( void (*main)( CRunner * ) ) { return new( main ); } void cfathread_join( CRunner * thrd ) { delete( thrd ); } void cfathread_park( void ) { park(); } void cfathread_unpark( CRunner * thrd ) { unpark( *thrd ); } void cfathread_yield( void ) { yield(); } //-------------------- // Basic kernel features void cfathread_setproccnt( int ncnt ) { assert( ncnt >= 1 ); adelete( procs ); proc_cnt = ncnt - 1; procs = anew(proc_cnt); } }