线程优先级(not进程)?
sched_setscheduler()可以设置指定进程的调度策略和优先级:http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=4241877
疑问:
1. sched_setscheduler()的功能,就是进入内核态,通过pid找到对应的task_struct结构,并修改吧?
2. 线程也有自己独立的task_struct结构吧?那么按道理,实现类似“set_thread_scheduler(pid, tid, sched)”也是可以的吧?只是要通过(pid,tid)的组合去找对应的task_struct结构。
请问目前有这样的函数吗?如果有这样的函数,还有可以获取某个进程所有线程id的函数吗?
比如,进程pidA有两个线程tid1、tid2。进程B先通过get_tids(pidA)获得tid1、tid2,然后通过“set_thread_scheduler()”分别去设置这两个线程的调度策略和优先级。
相关:
int setpriority(int which, int who, int prio);// 这个函数和sched_setscheduler()在用途方面,和sched_setscheduler()有什么区别和联系不?
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);// pthread_attr_t结构中有个跟调度策略相关的成员,但不能在第三方进程使用
页:
[1]