シングルスレッドのアプリケーションがあります。以下のコードを使用すると、が得られsched_setscheduler(): Operation not permitted
ます。
struct sched_param param;
param.sched_priority = 1;
if (sched_setscheduler(getpid(), SCHED_RR, ¶m))
printf(stderr, "sched_setscheduler(): %s\n", strerror(errno));
しかし、以下のようなpthread apiを使用しても、エラーは発生しません。シングルスレッドアプリケーションの2つの違いは何ですか?以下の関数は実際にスケジューラと優先度を変更しますか、それともエラー処理がありませんか?
void assignRRPriority(int tPriority)
{
int policy;
struct sched_param param;
pthread_getschedparam(pthread_self(), &policy, ¶m);
param.sched_priority = tPriority;
if(pthread_setschedparam(pthread_self(), SCHED_RR, ¶m))
printf("error while setting thread priority to %d", tPriority);
}