Changeset 29185fc
- Timestamp:
- Sep 30, 2020, 4:44:22 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 4e39f51
- Parents:
- d035cf7
- Location:
- doc/theses/thierry_delisle_PhD/code/readQ_example
- Files:
-
- 3 added
- 1 deleted
- 1 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/thierry_delisle_PhD/code/readQ_example/proto-gui/main.cpp
rd035cf7 r29185fc 1 #include "thrdlib/thread.h "1 #include "thrdlib/thread.hpp" 2 2 3 3 #include <cassert> … … 10 10 11 11 #include <getopt.h> 12 using thrdlib::thread_t; 13 12 14 13 15 //-------------------- … … 37 39 assert( expected == reset ); 38 40 if( std::atomic_compare_exchange_strong( &state, &expected, self) ) { 39 thrdlib _park( self );41 thrdlib::park( self ); 40 42 ret = true; 41 43 goto END; … … 55 57 if( got == reset ) return false; 56 58 57 thrdlib _unpark( got );59 thrdlib::unpark( got ); 58 60 return true; 59 61 } … … 110 112 the_stats_thread = self; 111 113 fence(); 112 thrdlib _park( self );114 thrdlib::park( self ); 113 115 114 116 std::vector<bool> seen; … … 116 118 117 119 while(last_produced < nproduce) { 118 thrdlib _yield();120 thrdlib::yield(); 119 121 thrd_stats.stats.ran++; 120 122 if( last_produced > 0 ) seen.at(last_produced - 1) = true; … … 148 150 149 151 void Renderer( thread_t self ) { 150 thrdlib _unpark( the_stats_thread );152 thrdlib::unpark( the_stats_thread ); 151 153 for(unsigned i = 0; i < nproduce; i++) { 152 154 auto & frame = frames[i % nframes]; … … 247 249 std::cout << "(Buffering " << nframes << ")" << std::endl; 248 250 249 thrdlib _init(2 );250 251 thread_t stats = thrdlib _create( Stats);251 thrdlib::init( "fibre", 2 ); 252 253 thread_t stats = thrdlib::create( Stats ); 252 254 std::cout << "Created Stats Thread" << std::endl; 253 while( the_stats_thread == nullptr ) thrdlib_yield(); 255 while( the_stats_thread == nullptr ) thrdlib::yield(); 256 254 257 std::cout << "Creating Main Threads" << std::endl; 255 thread_t renderer = thrdlib_create( Renderer ); 256 // while(true); 257 thread_t simulator = thrdlib_create( Simulator ); 258 thread_t renderer = thrdlib::create( Renderer ); 259 thread_t simulator = thrdlib::create( Simulator ); 258 260 259 261 std::cout << "Running" << std::endl; 260 262 261 thrdlib _join( simulator );262 thrdlib _join( renderer );263 thrdlib _join( stats );264 265 thrdlib _clean();263 thrdlib::join( simulator ); 264 thrdlib::join( renderer ); 265 thrdlib::join( stats ); 266 267 thrdlib::clean(); 266 268 267 269 std::cout << "----------" << std::endl; -
doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/fibre.cpp
rd035cf7 r29185fc 1 #pragma once2 3 1 #include <cassert> 4 2 #include <libfibre/cfibre.h> 5 3 6 #if defined(__cforall) || defined(__cpluplus) 4 typedef cfibre_t thread_t; 5 static_assert(sizeof(thread_t) == sizeof(void*), "thread_t musst be of same size as void*"); 6 7 void * fibre_runner(void * arg) { 8 auto the_main = (void (*)( thread_t ))arg; 9 the_main( cfibre_self() ); 10 return nullptr; 11 } 12 7 13 extern "C" { 8 #endif9 //--------------------10 // Basic types11 typedef cfibre_t thread_t;12 13 void * fibre_runner(void * arg) {14 auto the_main = (void (*)( thread_t ))arg;15 the_main( cfibre_self() );16 return nullptr;17 }18 19 14 //-------------------- 20 15 // Basic thread support … … 51 46 52 47 } 53 54 55 #if defined(__cforall) || defined(__cpluplus)56 48 } 57 #endif -
doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/pthread.cpp
rd035cf7 r29185fc 1 #pragma once2 3 1 #include <pthread.h> 4 2 #include <errno.h> … … 56 54 #undef CHECKED 57 55 58 #if defined(__cforall) || defined(__cpluplus) 56 //-------------------- 57 // Basic types 58 struct pthread_runner_t { 59 pthread_t handle; 60 __bin_sem_t sem; 61 }; 62 typedef pthread_runner_t * thread_t; 63 64 static_assert(sizeof(thread_t) == sizeof(void*), "thread_t musst be of same size as void*"); 65 59 66 extern "C" { 60 #endif61 //--------------------62 // Basic types63 struct pthread_runner_t {64 pthread_t handle;65 __bin_sem_t sem;66 };67 typedef pthread_runner_t * thread_t;68 69 67 //-------------------- 70 68 // Basic thread support … … 99 97 // Basic kernel features 100 98 void thrdlib_init( int ) {} 101 void thrdlib_clean( void ) {}102 103 104 #if defined(__cforall) || defined(__cpluplus)105 99 } 106 #endif
Note: See TracChangeset
for help on using the changeset viewer.