51 pthread_mutex_init(&
mMutex, NULL);
52 pthread_cond_init(&
mCond, NULL);
56 pthread_mutex_destroy(&
mMutex);
57 pthread_cond_destroy(&
mCond);
77 pthread_attr_init(&mAttributes);
101 pthread_attr_setdetachstate(&
mAttributes, PTHREAD_CREATE_DETACHED);
102 pthread_attr_setscope(&
mAttributes, PTHREAD_SCOPE_SYSTEM);
106 #ifdef CSL_MACOSX_OLD_WAY
110 #include <mach/mach.h>
112 unsigned GetThreadBasePriority (pthread_t inThread) {
113 thread_basic_info_data_t threadInfo;
114 policy_info_data_t thePolicyInfo;
118 count = THREAD_BASIC_INFO_COUNT;
119 thread_info (pthread_mach_thread_np (inThread), THREAD_BASIC_INFO, (integer_t*)&threadInfo, &count);
120 switch (threadInfo.policy) {
121 case POLICY_TIMESHARE:
122 count = POLICY_TIMESHARE_INFO_COUNT;
123 thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_TIMESHARE_INFO, (integer_t*)&(thePolicyInfo.ts), &count);
124 return thePolicyInfo.ts.base_priority;
127 count = POLICY_FIFO_INFO_COUNT;
128 thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_FIFO_INFO, (integer_t*)&(thePolicyInfo.fifo), &count);
129 if (thePolicyInfo.fifo.depressed) {
130 return thePolicyInfo.fifo.depress_priority;
132 return thePolicyInfo.fifo.base_priority;
136 count = POLICY_RR_INFO_COUNT;
137 thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_RR_INFO, (integer_t*)&(thePolicyInfo.rr), &count);
138 if (thePolicyInfo.rr.depressed)
139 return thePolicyInfo.rr.depress_priority;
141 return thePolicyInfo.rr.base_priority;
147 int ThreadPthread::createRealtimeThread(
VoidFcnPtr * func,
void* args) {
151 int threadPriority = 62;
155 thread_extended_policy_data_t theFixedPolicy;
156 thread_precedence_policy_data_t thePrecedencePolicy;
157 int relativePriority;
159 theFixedPolicy.timeshare =
false;
160 result = thread_policy_set (pthread_mach_thread_np(
mThread), THREAD_EXTENDED_POLICY, (thread_policy_t)&theFixedPolicy, THREAD_EXTENDED_POLICY_COUNT);
163 relativePriority = threadPriority - GetThreadBasePriority (pthread_self());
164 thePrecedencePolicy.importance = relativePriority;
165 result = thread_policy_set (pthread_mach_thread_np(
mThread), THREAD_PRECEDENCE_POLICY, (thread_policy_t)&thePrecedencePolicy, THREAD_PRECEDENCE_POLICY_COUNT);