History

cleaned up code for thread priority

Ge Wang committed 5 years ago

Commit 5dac7891 parent 4d3eb573 files · +66 −31Browse files

Showing the changes to src/core/util_thread.cpp (1 of 3 files). Show all

Unified · Split

src/core/util_thread.cpp+36−4
@@ -492,20 +492,35 @@ t_CKBOOL XThreadUtil::set_priority( CHUCK_THREAD tid, t_CKINT priority ) · 491 unmodified lines
492 int policy;492 int policy;
493 493
494 // log494 // log
495 EM_log( CK_LOG_FINE, "setting thread priority to: %ld...", priority );495 EM_log( CK_LOG_INFO, "setting thread priority to: %ld...", priority );
496 496
497 // get for thread497 // get for thread
498 if( pthread_getschedparam( tid, &policy, &param) )498 if( pthread_getschedparam( tid, &policy, &param) )
499 return FALSE;499 return FALSE;
500 500
501 // priority501 // pthread_attr_t attr;
502 param.sched_priority = priority;502 // pthread_attr_init( &attr );
503 // pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
504
503 // policy505 // policy
504 policy = SCHED_RR;506 policy = SCHED_RR;
507 // priority
508 param.sched_priority = priority;
505 // set for thread, pthread style509 // set for thread, pthread style
506 if( pthread_setschedparam( tid, policy, &param ) )510 if( pthread_setschedparam( tid, policy, &param ) )
507 return FALSE;511 return FALSE;
508 512
513 // get for thread
514 if( pthread_getschedparam( tid, &policy, &param) )
515 return FALSE;
516
517 // push
518 EM_pushlog();
519 // log
520 EM_log( CK_LOG_FINE, "verifying thread priority: %ld...", param.sched_priority );
521 // pop
522 EM_poplog();
523
509 return TRUE;524 return TRUE;
510}525}
511//-----------------------------------------------------------------------------526//-----------------------------------------------------------------------------
@@ -518,6 +533,14 @@ t_CKBOOL XThreadUtil::set_priority( t_CKINT priority ) · 6 unmodified lines
518 set_priority( pthread_self(), priority );533 set_priority( pthread_self(), priority );
519 return TRUE;534 return TRUE;
520}535}
536t_CKINT XThreadUtil::get_max_priority()
537{
538 return sched_get_priority_max( SCHED_RR );
539}
540t_CKINT XThreadUtil::get_min_priority()
541{
542 return sched_get_priority_min( SCHED_RR );
543}
521#else544#else
522//-----------------------------------------------------------------------------545//-----------------------------------------------------------------------------
523// name: set_priority()546// name: set_priority()
@@ -547,4 +570,13 @@ t_CKBOOL XThreadUtil::set_priority( t_CKINT priority ) · 23 unmodified lines
547 set_priority( GetCurrentThread(), priority );570 set_priority( GetCurrentThread(), priority );
548 return TRUE;571 return TRUE;
549}572}
573t_CKINT XThreadUtil::get_max_priority()
574{
575 return THREAD_PRIORITY_HIGHEST; // THREAD_PRIORITY_TIME_CRITICAL;
576}
577t_CKINT XThreadUtil::get_min_priority()
578{
579 return THREAD_PRIORITY_LOWEST;
580}
550#endif581#endif
582

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t