Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SetThreadPriority #786

Merged
merged 4 commits into from
Oct 19, 2015
Merged

Implement SetThreadPriority #786

merged 4 commits into from
Oct 19, 2015

Conversation

codemercenary
Copy link
Contributor

@gittyupagain implemented this functionality on a private branch awhile back, let's get it into mainline.

Fixes #784

@gittyupagain implemented this functionality on a private branch awhile back, let's get it into mainline.
default:
throw std::runtime_error("Attempted to assign an unrecognized thread priority");
}
param.sched_priority = PTHREAD_MIN_PRIORITY + (percent*(PTHREAD_MAX_PRIORITY - PTHREAD_MIN_PRIORITY) + 50) / 100;
Copy link
Contributor

Choose a reason for hiding this comment

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

#include <sched.h>
int sched_get_priority_max(int policy);
int sched_get_priority_min(int policy);
should be used here.

@hham hham force-pushed the feature-threadpriority branch from e399eea to c480b3e Compare October 15, 2015 23:06
#define PTHREAD_MIN_PRIORITY 0
#endif
#if !defined(PTHREAD_MAX_PRIORITY)
#define PTHREAD_MAX_PRIORITY 31
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like 63 is max priority in user space according to https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/KernelProgramming/scheduler/scheduler.html.
Why did you put 31?

Copy link
Contributor

Choose a reason for hiding this comment

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

This was done 20 months ago and never pushed. It was an initial attempt at the problem. Those numbers probably came from Linux documentation. It is unfortunate that it isn't defined. If 63 is correct, then that should be used instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll make the change.

gittyupagain pushed a commit that referenced this pull request Oct 19, 2015
@gittyupagain gittyupagain merged commit 391c407 into develop Oct 19, 2015
@gittyupagain gittyupagain deleted the feature-threadpriority branch October 19, 2015 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants