Showing the changes to src/core/util_thread.cpp (1 of 3 files). Show all
Unified · Split
| @@ -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 | // log | 494 | // 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 thread | 497 | // get for thread |
| 498 | if( pthread_getschedparam( tid, &policy, ¶m) ) | 498 | if( pthread_getschedparam( tid, &policy, ¶m) ) |
| 499 | return FALSE; | 499 | return FALSE; |
| 500 | 500 | ||
| 501 | // priority | 501 | // pthread_attr_t attr; |
| 502 | param.sched_priority = priority; | 502 | // pthread_attr_init( &attr ); |
| 503 | // pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); | ||
| 504 | |||
| 503 | // policy | 505 | // policy |
| 504 | policy = SCHED_RR; | 506 | policy = SCHED_RR; |
| 507 | // priority | ||
| 508 | param.sched_priority = priority; | ||
| 505 | // set for thread, pthread style | 509 | // set for thread, pthread style |
| 506 | if( pthread_setschedparam( tid, policy, ¶m ) ) | 510 | if( pthread_setschedparam( tid, policy, ¶m ) ) |
| 507 | return FALSE; | 511 | return FALSE; |
| 508 | 512 | ||
| 513 | // get for thread | ||
| 514 | if( pthread_getschedparam( tid, &policy, ¶m) ) | ||
| 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 | } |
| 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 | } | ||
| 521 | #else | 544 | #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 | } |
| 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 | } | ||
| 550 | #endif | 581 | #endif |
| 582 | |||