- 论坛徽章:
- 0
|
回复 19# windoze
这是我的一点代码片段,按照你的意思,我的线程已经是实时线程了?这样线程就不会被打断吗
//add by matchbox
cpu_set_t sCPUSet;
CPU_ZERO( &sCPUSet );
CPU_SET( 0, &sCPUSet );
pthread_attr_t attr;
struct sched_param thread_param;
pthread_attr_init (&attr);
int policy = -1;
thread_param.__sched_priority = 99;
thread_param1.__sched_priority = 10;
pthread_attr_setschedpolicy(&attr, SCHED_FIFO); //设置调度方式为FIFO
pthread_attr_setschedparam(&attr, &thread_param);//优先级调到最高
//pthread_attr_getschedpolicy(&attr, &policy);
//pthread_attr_getschedparam(&attr, &thread_param1);
//pthread_getaffinity_np(pthread_self(),sizeof( sCPUSet ),&sCPUSet);
sched_setaffinity(0,sizeof(cpu_set_t),&sCPUSet);//进程绑定到cpu0
//add end;
|
|