Changeset 6a490b2 for libcfa/src/concurrency/kernel.hfa
- Timestamp:
- May 11, 2020, 1:53:29 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:
- 504a7dc
- Parents:
- b7d6a36 (diff), a7b486b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.hfa
rb7d6a36 r6a490b2 17 17 18 18 #include <stdbool.h> 19 #include <stdint.h> 19 20 20 21 #include "invoke.h" … … 32 33 __spinlock_t lock; 33 34 int count; 34 __queue_t( thread_desc) waiting;35 __queue_t($thread) waiting; 35 36 }; 36 37 37 38 void ?{}(semaphore & this, int count = 1); 38 39 void ^?{}(semaphore & this); 39 void P (semaphore & this); 40 void V (semaphore & this); 40 bool P (semaphore & this); 41 bool V (semaphore & this); 42 bool V (semaphore & this, unsigned count); 41 43 42 44 … … 44 46 // Processor 45 47 extern struct cluster * mainCluster; 46 47 enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule, Release_Multi, Release_Multi_Schedule, Callback };48 49 typedef void (*__finish_callback_fptr_t)(void);50 51 //TODO use union, many of these fields are mutually exclusive (i.e. MULTI vs NOMULTI)52 struct FinishAction {53 FinishOpCode action_code;54 /*55 // Union of possible actions56 union {57 // Option 1 : locks and threads58 struct {59 // 1 thread or N thread60 union {61 thread_desc * thrd;62 struct {63 thread_desc ** thrds;64 unsigned short thrd_count;65 };66 };67 // 1 lock or N lock68 union {69 __spinlock_t * lock;70 struct {71 __spinlock_t ** locks;72 unsigned short lock_count;73 };74 };75 };76 // Option 2 : action pointer77 __finish_callback_fptr_t callback;78 };79 /*/80 thread_desc * thrd;81 thread_desc ** thrds;82 unsigned short thrd_count;83 __spinlock_t * lock;84 __spinlock_t ** locks;85 unsigned short lock_count;86 __finish_callback_fptr_t callback;87 //*/88 };89 static inline void ?{}(FinishAction & this) {90 this.action_code = No_Action;91 this.thrd = 0p;92 this.lock = 0p;93 }94 static inline void ^?{}(FinishAction &) {}95 48 96 49 // Processor … … 117 70 // RunThread data 118 71 // Action to do after a thread is ran 119 struct FinishAction finish;72 $thread * destroyer; 120 73 121 74 // Preemption data … … 126 79 bool pending_preemption; 127 80 128 // Idle lock 129 __bin_sem_t idle Lock;81 // Idle lock (kernel semaphore) 82 __bin_sem_t idle; 130 83 131 84 // Termination … … 133 86 volatile bool do_terminate; 134 87 135 // Termination synchronisation 88 // Termination synchronisation (user semaphore) 136 89 semaphore terminated; 137 90 … … 158 111 static inline void ?{}(processor & this, const char name[]) { this{name, *mainCluster }; } 159 112 160 static inline [processor *&, processor *& ] __get( processor & this ) { 161 return this.node.[next, prev]; 162 } 113 static inline [processor *&, processor *& ] __get( processor & this ) __attribute__((const)) { return this.node.[next, prev]; } 114 115 //----------------------------------------------------------------------------- 116 // I/O 117 struct __io_data; 118 119 #define CFA_CLUSTER_IO_POLLER_USER_THREAD 1 << 0 120 // #define CFA_CLUSTER_IO_POLLER_KERNEL_SIDE 1 << 1 163 121 164 122 … … 333 291 // List of threads 334 292 __spinlock_t thread_list_lock; 335 __dllist_t(struct thread_desc) threads;293 __dllist_t(struct $thread) threads; 336 294 unsigned int nthreads; 337 295 … … 341 299 cluster * prev; 342 300 } node; 301 302 struct __io_data * io; 303 304 #if !defined(__CFA_NO_STATISTICS__) 305 bool print_stats; 306 #endif 343 307 }; 344 308 extern Duration default_preemption(); 345 309 346 void ?{} (cluster & this, const char name[], Duration preemption_rate );310 void ?{} (cluster & this, const char name[], Duration preemption_rate, int flags); 347 311 void ^?{}(cluster & this); 348 312 349 static inline void ?{} (cluster & this) { this{"Anonymous Cluster", default_preemption()}; } 350 static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate}; } 351 static inline void ?{} (cluster & this, const char name[]) { this{name, default_preemption()}; } 352 353 static inline [cluster *&, cluster *& ] __get( cluster & this ) { 354 return this.node.[next, prev]; 355 } 313 static inline void ?{} (cluster & this) { this{"Anonymous Cluster", default_preemption(), 0}; } 314 static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate, 0}; } 315 static inline void ?{} (cluster & this, const char name[]) { this{name, default_preemption(), 0}; } 316 static inline void ?{} (cluster & this, int flags) { this{"Anonymous Cluster", default_preemption(), flags}; } 317 static inline void ?{} (cluster & this, Duration preemption_rate, int flags) { this{"Anonymous Cluster", preemption_rate, flags}; } 318 static inline void ?{} (cluster & this, const char name[], int flags) { this{name, default_preemption(), flags}; } 319 320 static inline [cluster *&, cluster *& ] __get( cluster & this ) __attribute__((const)) { return this.node.[next, prev]; } 356 321 357 322 static inline struct processor * active_processor() { return TL_GET( this_processor ); } // UNSAFE 358 323 static inline struct cluster * active_cluster () { return TL_GET( this_processor )->cltr; } 324 325 #if !defined(__CFA_NO_STATISTICS__) 326 static inline void print_stats_at_exit( cluster & this ) { 327 this.print_stats = true; 328 } 329 #endif 359 330 360 331 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.