Changeset 9236060 for src/libcfa/concurrency/kernel
- Timestamp:
- Aug 14, 2017, 2:03:39 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 74b007ba
- Parents:
- fd344aa (diff), 54cd58b (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
-
src/libcfa/concurrency/kernel
rfd344aa r9236060 1 // -*- Mode: CFA -*-2 1 // 3 2 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo … … 10 9 // Author : Thierry Delisle 11 10 // Created On : Tue Jan 17 12:27:26 2017 12 // Last Modified By : Thierry Delisle13 // Last Modified On : --14 // Update Count : 011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:58:39 2017 13 // Update Count : 2 15 14 // 16 15 17 #ifndef KERNEL_H 18 #define KERNEL_H 16 #pragma once 19 17 20 18 #include <stdbool.h> … … 28 26 //----------------------------------------------------------------------------- 29 27 // Locks 30 bool try_lock ( spinlock * DEBUG_CTX_PARAM2 ); 31 void lock ( spinlock * DEBUG_CTX_PARAM2 );32 void lock_yield( spinlock * DEBUG_CTX_PARAM2 ); 33 void unlock ( spinlock * ); 28 void lock ( spinlock * DEBUG_CTX_PARAM2 ); // Lock the spinlock, spin if already acquired 29 void lock_yield( spinlock * DEBUG_CTX_PARAM2 ); // Lock the spinlock, yield repeatedly if already acquired 30 bool try_lock ( spinlock * DEBUG_CTX_PARAM2 ); // Lock the spinlock, return false if already acquired 31 void unlock ( spinlock * ); // Unlock the spinlock 34 32 35 33 struct semaphore { … … 48 46 // Cluster 49 47 struct cluster { 50 __thread_queue_t ready_queue; 51 spinlock lock; 48 spinlock ready_queue_lock; // Ready queue locks 49 __thread_queue_t ready_queue; // Ready queue for threads 50 unsigned long long int preemption; // Preemption rate on this cluster 52 51 }; 53 52 … … 76 75 static inline void ^?{}(FinishAction & this) {} 77 76 77 // Processor 78 // Wrapper around kernel threads 78 79 struct processor { 79 struct processorCtx_t * runner; 80 cluster * cltr; 81 pthread_t kernel_thread; 80 // Main state 81 struct processorCtx_t * runner; // Coroutine ctx who does keeps the state of the processor 82 cluster * cltr; // Cluster from which to get threads 83 pthread_t kernel_thread; // Handle to pthreads 82 84 83 semaphore terminated; 84 volatile bool is_terminated; 85 // Termination 86 volatile bool do_terminate; // Set to true to notify the processor should terminate 87 semaphore terminated; // Termination synchronisation 85 88 86 struct FinishAction finish; 89 // RunThread data 90 struct FinishAction finish; // Action to do after a thread is ran 87 91 88 struct alarm_node_t * preemption_alarm; 89 unsigned int preemption; 92 // Preemption data 93 struct alarm_node_t * preemption_alarm; // Node which is added in the discrete event simulaiton 94 bool pending_preemption; // If true, a preemption was triggered in an unsafe region, the processor must preempt as soon as possible 90 95 91 bool pending_preemption; 92 93 char * last_enable; 96 #ifdef __CFA_DEBUG__ 97 char * last_enable; // Last function to enable preemption on this processor 98 #endif 94 99 }; 95 100 … … 98 103 void ^?{}(processor & this); 99 104 100 #endif //KERNEL_H101 102 105 // Local Variables: // 103 // mode: CFA//104 // tab-width: 6//106 // mode: c // 107 // tab-width: 4 // 105 108 // End: //
Note: See TracChangeset
for help on using the changeset viewer.