Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Fix 13058 - Thread priority handling doesn't work in Solaris #871

Merged
merged 9 commits into from
Jul 15, 2014

Conversation

jasonbking
Copy link

This fixes (or rather works around a long standing Solaris bug) dealing with adjusting a thread's priority. The workaround is to merely utilize the underlying interfaces that the posix functions call.

Utilizing the underlying interface also allows us to obtain the effective maximum priority instead of the absolute maximum. On Solaris systems, typically priorities range from [-60, 60], however non-privileged processes have a cap at 0, effectively limiting them to [-60, 0] (though an admin can change this on the fly). This includes code that (at startup) determines the effective range and uses that as that seems likely to be the best fit to the existing thread.d API.

With the workaround, the tests pass, without it, it fails in adjusting the thread priority back to it's original value.

https://issues.dlang.org/show_bug.cgi?id=13058

enum PC_KY_NULL = 0; // kv chain terminator
enum PC_KY_CLNAME = 1; // get the class name of a process or LWP

struct pc_vaparm_t {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} on a separate line please ;-)

@jpf91
Copy link
Contributor

jpf91 commented Jul 12, 2014

LGTM except for a few code style nitpicks.

I don't know if this is the 'correct' way to solve this issue for solaris but I doubt there's anyone in the core contributor team who has enough solaris experience to double-check this. But the code is well-documented and no reason not to trust @jasonbking that this solution is correct and it certainly won't do any harm.

So if these minor style issues are fixed this should be ready to get merged.
ping @ibuclaw

@jasonbking
Copy link
Author

Should all be fixed (plus noticed a very minor typo in one of the exception messages).

I can point to the relevant Illumos code, though it'd be a bit involved as both posix functions get about 2-3 functions deep before you get to the common function they all call (which is where the bug is), though it also shows they just call priocntl(2) to implement their interfaces.

alexrp pushed a commit that referenced this pull request Jul 15, 2014
Fix 13058 - Thread priority handling doesn't work in Solaris
@alexrp alexrp merged commit 6bcb802 into dlang:master Jul 15, 2014
@jasonbking jasonbking deleted the thread_priority branch July 17, 2014 02:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants