61 pthread_mutex_init(&
mMutex, NULL);
62 pthread_cond_init(&
mCond, NULL);
66 pthread_mutex_destroy(&
mMutex);
67 pthread_cond_destroy(&
mCond);
87 pthread_attr_init(&mAttributes);
111 pthread_attr_setdetachstate(&
mAttributes, PTHREAD_CREATE_DETACHED);
112 pthread_attr_setscope(&
mAttributes, PTHREAD_SCOPE_SYSTEM);
116 #ifdef CSL_MACOSX_OLD_WAY
120 #include <mach/mach.h>
122 unsigned GetThreadBasePriority (pthread_t inThread) {
123 thread_basic_info_data_t threadInfo;
124 policy_info_data_t thePolicyInfo;
128 count = THREAD_BASIC_INFO_COUNT;
129 thread_info (pthread_mach_thread_np (inThread), THREAD_BASIC_INFO, (integer_t*)&threadInfo, &count);
130 switch (threadInfo.policy) {
131 case POLICY_TIMESHARE:
132 count = POLICY_TIMESHARE_INFO_COUNT;
133 thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_TIMESHARE_INFO, (integer_t*)&(thePolicyInfo.ts), &count);
134 return thePolicyInfo.ts.base_priority;
137 count = POLICY_FIFO_INFO_COUNT;
138 thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_FIFO_INFO, (integer_t*)&(thePolicyInfo.fifo), &count);
139 if (thePolicyInfo.fifo.depressed) {
140 return thePolicyInfo.fifo.depress_priority;
142 return thePolicyInfo.fifo.base_priority;
146 count = POLICY_RR_INFO_COUNT;
147 thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_RR_INFO, (integer_t*)&(thePolicyInfo.rr), &count);
148 if (thePolicyInfo.rr.depressed)
149 return thePolicyInfo.rr.depress_priority;
151 return thePolicyInfo.rr.base_priority;
157 int ThreadPthread::createRealtimeThread(
VoidFcnPtr * func,
void* args) {
161 int threadPriority = 62;
165 thread_extended_policy_data_t theFixedPolicy;
166 thread_precedence_policy_data_t thePrecedencePolicy;
167 int relativePriority;
169 theFixedPolicy.timeshare =
false;
170 result = thread_policy_set (pthread_mach_thread_np(
mThread), THREAD_EXTENDED_POLICY, (thread_policy_t)&theFixedPolicy, THREAD_EXTENDED_POLICY_COUNT);
173 relativePriority = threadPriority - GetThreadBasePriority (pthread_self());
174 thePrecedencePolicy.importance = relativePriority;
175 result = thread_policy_set (pthread_mach_thread_np(
mThread), THREAD_PRECEDENCE_POLICY, (thread_policy_t)&thePrecedencePolicy, THREAD_PRECEDENCE_POLICY_COUNT);
void logMsg(const char *format,...)
These are the public logging messages.
The PThreads CSL Thread class.
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
pthread_attr_t mAttributes
static Synch * MakeSynch()
Factory method Utilities.
Sync is a cross-thread synchronization object.
void stopThread(int timeOutMilliseconds)
void * VoidFcnPtr(void *arg)
the generic void fcn pointer
PThread version of Thread.
virtual int createThread(VoidFcnPtr *func, void *args)=0
static CThread * MakeThread()
factory method
int createThread(VoidFcnPtr *func, void *args)