08/24/2009 10:21 AM
post36515
|
SCHED_SETPRIO is used for pthread_setschedprio() - for some reason this is not doc'd
http://www.opengroup.org/onlinepubs/009695399/functions/pthread_setschedprio.html
The rationale says it all...
RATIONALE
The pthread_setschedprio() function provides a way for an application to temporarily raise its priority and then
lower it again, without having the undesired side effect of yielding to other threads of the same priority. This is
necessary if the
application is to implement its own strategies for bounding priority inversion, such as priority inheritance or priority
ceilings. This capability is especially important if the implementation does not support the Thread Priority Protection
or Thread
Priority Inheritance options, but even if those options are supported it is needed if the application is to bound
priority inheritance for other resources, such as semaphores.
The standard developers considered that while it might be preferable conceptually to solve this problem by
modifying the specification of pthread_setschedparam(), it was too late to make such a change, as there may be
implementations that would
need to be changed. Therefore, this new function was introduced.
Sönke Nielsen wrote:
> In ker/nano_sched.c sched_thread()
>
> Why does a thread goes to the head of the priority queue in case of a lower priority?
>
> if (new_prio != thp->priority) {
> int lowered = (new_prio < thp->priority);
>
> adjust_priority(thp, new_prio, thp->dpp, 0);
>
> // If we lowered priority, ensure we will be head of priority list
> if (lowered && thp->state == STATE_READY) {
> LINK3_REM(DISPATCH_LST(thp->dpp, thp->priority), thp, THREAD);
> LINK3_BEG(DISPATCH_LST(thp->dpp, thp->priority), thp, THREAD);
> }
> }
>
> Thanks
> Sönke
>
>
>
> _______________________________________________
>
> OSTech
> http://community.qnx.com/sf/go/post36495
--
cburgess@qnx.com
|
|
|