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
492492 int policy;
493493
494494 // 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 );
496496
497497 // get for thread
498498 if( pthread_getschedparam( tid, &policy, &param) )
499499 return FALSE;
500500
501− // priority
502− param.sched_priority = priority;
501+ // pthread_attr_t attr;
502+ // pthread_attr_init( &attr );
503+ // pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
504+
503505 // policy
504506 policy = SCHED_RR;
507+ // priority
508+ param.sched_priority = priority;
505509 // set for thread, pthread style
506510 if( pthread_setschedparam( tid, policy, &param ) )
507511 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+
509524 return TRUE;
510525 }
511526 //-----------------------------------------------------------------------------
@@ -518,6 +533,14 @@ t_CKBOOL XThreadUtil::set_priority( t_CKINT priority ) · 6 unmodified lines
518533 set_priority( pthread_self(), priority );
519534 return TRUE;
520535 }
536+t_CKINT XThreadUtil::get_max_priority()
537+{
538+ return sched_get_priority_max( SCHED_RR );
539+}
540+t_CKINT XThreadUtil::get_min_priority()
541+{
542+ return sched_get_priority_min( SCHED_RR );
543+}
521544 #else
522545 //-----------------------------------------------------------------------------
523546 // name: set_priority()
@@ -547,4 +570,13 @@ t_CKBOOL XThreadUtil::set_priority( t_CKINT priority ) · 23 unmodified lines
547570 set_priority( GetCurrentThread(), priority );
548571 return TRUE;
549572 }
573+t_CKINT XThreadUtil::get_max_priority()
574+{
575+ return THREAD_PRIORITY_HIGHEST; // THREAD_PRIORITY_TIME_CRITICAL;
576+}
577+t_CKINT XThreadUtil::get_min_priority()
578+{
579+ return THREAD_PRIORITY_LOWEST;
580+}
550581 #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