首页 > 代码库 > thread_8
thread_8
#include <stdlib.h> #include <pthread.h> #include <stdio.h> #include <sched.h> void *consumer(void *p) { int i; printf("start (%d)\n", (int)p); for (i = 0; 1; i++) { sleep(1); printf("<<<<<<<<<<<<<<<<<<<<<wake(%d)\n", (int)p); } } int main(int argc, char *argv[]) { pthread_t t1, t2, t3; struct sched_param sched3, sched4; sched3.__sched_priority = 70; int policy; pthread_create(&t1, NULL, consumer, (void *)4); pthread_create(&t2, NULL, consumer, (void *)5); pthread_create(&t3, NULL, (consumer), (void *)6); sleep(4); pthread_setschedparam(t3, SCHED_FIFO, &sched3); printf("main run\n"); pthread_getschedparam(t3, &policy, &sched4); printf("policy: %d, priority: %d\n", policy, sched4.__sched_priority); exit(1); pthread_join(t1, NULL); pthread_join(t2, NULL); pthread_join(t3, NULL); return 0; }
thread_8
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。