linux 线程(FIFO)先进先出
#include static int get_thread_priority( pthread_attr_t &attr ){ struct sched_param param; int rs = pthread_attr_getschedparam( &attr, ¶m ); assert( rs == 0 );
#include<pthread.h>
static int get_thread_priority( pthread_attr_t &attr )
{
struct sched_param param;
int rs = pthread_attr_getschedparam( &attr, ¶m );
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 , ¶m);
int priority = get_thread_priority( attr );
return 0;
}
输出1更多推荐
所有评论(0)