pthread priority setting

Posted on

Use pthread_attr_setschedparam() to set priority. the structure struct sched_param is used by this API. Set the priority for the thread to the member sched_priority in struct sched_param as you want. ** only priority sched_param.sched_priority is supported.

prototype:

int pthread_attr_setschedparam(pthread_attr_t *tattr, const struct sched_param *param);

example:

#include
pthread_t thread;
pthread_attr_t tattr;
sched_param param;
int ret ;
ret = sched_get_priority_max( PTHREAD_EXPLICIT_SCHED );
param.sched_priority = (ret

other related APIs:
int sched_get_priority_max(int policy);
int sched_get_priority_min(int policy);
int sched_get_priority ();
where policy could be PTHREAD_EXPLICIT_SCHED or PTHREAD_INHERIT_SCHED

Reference :

廣告

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s