Changeset 213 in flair-src for trunk/lib/FlairCore/src/Thread_impl.cpp
- Timestamp:
- Jan 30, 2018, 5:47:12 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/Thread_impl.cpp
r206 r213 36 36 using namespace flair::core; 37 37 38 Thread_impl::Thread_impl(Thread *self, uint8_t priority ) {38 Thread_impl::Thread_impl(Thread *self, uint8_t priority,uint32_t stackSize) { 39 39 isRunning = false; 40 40 tobestopped = false; 41 41 is_suspended = false; 42 42 period_set = false; 43 this->stackSize = stackSize; 43 44 44 45 this->self = self; … … 78 79 void Thread_impl::Start(void) { 79 80 int status; 80 char errorMsg[256];81 82 81 isRunning = true; 83 82 tobestopped = false; 84 83 is_suspended = false; 85 84 85 Printf("Starting thread %s (priority=%i, stack size=%i bytes)\n",self->ObjectName().c_str(), priority,stackSize); 86 86 #ifdef __XENO__ 87 87 string th_name =TH_NAME; 88 88 89 #ifdef RT_STACK_SIZE 90 status = rt_task_create(&task_rt, th_name.c_str(), RT_STACK_SIZE, 89 status = rt_task_create(&task_rt, th_name.c_str(), stackSize, 91 90 (int)priority, T_JOINABLE); 92 #else 93 status = 94 rt_task_create(&task_rt, th_name.c_str(), 0, (int)priority, T_JOINABLE); 95 #endif // RT_STACK_SIZE 96 if (status != 0) { 91 92 if (status != 0) { 93 char errorMsg[256]; 97 94 self->Err("rt_task_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg))); 98 95 } else { … … 102 99 status = rt_task_start(&task_rt, &main_rt, (void *)this); 103 100 if (status != 0) { 101 char errorMsg[256]; 104 102 self->Err("rt_task_start error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg))); 105 103 } else { … … 115 113 } 116 114 117 #ifdef NRT_STACK_SIZE 118 if (pthread_attr_setstacksize(&attr, NRT_STACK_SIZE) != 0) { 115 if (pthread_attr_setstacksize(&attr, stackSize) != 0) { 119 116 self->Err("Error pthread_attr_setstacksize\n"); 120 117 } 121 #endif // NRT_STACK_SIZE122 118 123 119 if (pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED) != 0) { … … 320 316 321 317 void Thread_impl::PrintStats(void) { 318 Printf("Stopping thread %s\n", self->ObjectName().c_str()); 322 319 #ifdef __XENO__ 323 320 RT_TASK_INFO info; … … 333 330 if(last!=0) 334 331 #endif 335 { Printf("Thread::%s :\n", self->ObjectName().c_str());332 { 336 333 if(period_set) {Printf(" period (ns): %lld\n", period);}} 337 334 #ifdef __XENO__ … … 365 362 if (isRunning == true) { 366 363 int status; 367 char errorMsg[256]; 368 364 369 365 #ifdef __XENO__ 370 366 status = rt_task_join(&task_rt); … … 372 368 status = pthread_join(task_nrt, NULL); 373 369 #endif 374 if (status != 0) 370 if (status != 0) { 371 char errorMsg[256]; 375 372 self->Err("error %s\n", strerror_r(-status, errorMsg, sizeof(errorMsg))); 373 } 376 374 isRunning = false; 377 375 }
Note:
See TracChangeset
for help on using the changeset viewer.