Linux setpriority的替代选项(优先级进程、线程id、优先级)

Linux setpriority的替代选项(优先级进程、线程id、优先级),linux,multithreading,pthreads,Linux,Multithreading,Pthreads,给定-线程的线程id。 要求-设置线程id的Linux优先级。 约束-不能使用setpriority() 我试着使用下面的方法 pthread\u setschedprio(pthread\u t thread,intprio) pthread\u setschedparam(pthread\u t thread,int policy, const struct sched_param*param) 上述两个API都使用pthread\u t作为参数。我无法从线程id构造(typecast)pt

给定-线程的线程id。
要求-设置线程id的Linux优先级。
约束-不能使用setpriority()

我试着使用下面的方法

pthread\u setschedprio(pthread\u t thread,intprio)
pthread\u setschedparam(pthread\u t thread,int policy, const struct sched_param*param)

上述两个API都使用pthread\u t作为参数。我无法从线程id构造(typecast)pthread_t。我知道由于类型不同,无法进行转换


还有什么方法可以实现这一点吗?

使用
sched\u setparam
函数(在
中声明)的纯线程ID可以使用
pthread\u setchedprio
接口的某些方面。声明进程受到影响(这是POSIX强制的行为),但在Linux上


请记住,直接调用
sched_setparam
可能会破坏PI互斥体和其他同步原语的预期行为,因为直接调用不会执行由
pthread_
*函数执行的额外簿记。

从何处获取线程ID?谢谢。它像预期的那样工作。谷歌搜索时错过了API。