标签:style blog color io ar for sp div art
#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; }
标签:style blog color io ar for sp div art
原文地址:http://www.cnblogs.com/leijiangtao/p/3995810.html