码迷,mamicode.com
首页 > 其他好文 > 详细

thread_8

时间:2014-09-27 01:43:08      阅读:244      评论:0      收藏:0      [点我收藏+]

标签: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;
 }

 

thread_8

标签:style   blog   color   io   ar   for   sp   div   art   

原文地址:http://www.cnblogs.com/leijiangtao/p/3995810.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!