linux 線程(FIFO)先進先出

#include<pthread.h>

 

static int get_thread_priority( pthread_attr_t &attr )
{
        struct sched_param param;

        int rs = pthread_attr_getschedparam( &attr, &param );
        assert( rs == 0 );
       printf( "priority = %d\n", param.__sched_priority );

        return param.__sched_priority;
}


int main(int argc, char **argv)
{
 int res;
 pthread_t b_thread;

pthread_attr_t attr;
struct sched_param param;
param.sched_priority =1;
pthread_attr_init(&attr);
pthread_attr_setschedpolicy(&attr, SCHED_FIFO); pthread_attr_setschedparam(&attr , &param);
int priority = get_thread_priority( attr );

return 0;

}

輸出1
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章