#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
Logo

更多推荐