- 論壇徽章:
- 13
|
sched_setscheduler()可以設(shè)置指定進(jìn)程的調(diào)度策略和優(yōu)先級:
http://www.72891.cn/forum.php?mod=viewthread&tid=4241877
疑問:
1. sched_setscheduler()的功能,就是進(jìn)入內(nèi)核態(tài),通過pid找到對應(yīng)的task_struct結(jié)構(gòu),并修改吧?
2. 線程也有自己獨(dú)立的task_struct結(jié)構(gòu)吧?那么按道理,實(shí)現(xiàn)類似“set_thread_scheduler(pid, tid, sched)”也是可以的吧?只是要通過(pid,tid)的組合去找對應(yīng)的task_struct結(jié)構(gòu)。
請問目前有這樣的函數(shù)嗎?如果有這樣的函數(shù),還有可以獲取某個(gè)進(jìn)程所有線程id的函數(shù)嗎?
比如,進(jìn)程pidA有兩個(gè)線程tid1、tid2。進(jìn)程B先通過get_tids(pidA)獲得tid1、tid2,然后通過“set_thread_scheduler()”分別去設(shè)置這兩個(gè)線程的調(diào)度策略和優(yōu)先級。
相關(guān):
int setpriority(int which, int who, int prio); // 這個(gè)函數(shù)和sched_setscheduler()在用途方面,和sched_setscheduler()有什么區(qū)別和聯(lián)系不?
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); // pthread_attr_t結(jié)構(gòu)中有個(gè)跟調(diào)度策略相關(guān)的成員,但不能在第三方進(jìn)程使用 |
|