线程优先级设置和获取

来源:互联网 发布:永久免费域名注册 编辑:程序博客网 时间:2024/06/04 17:54
    pthread_attr_t thread_attr;
    int thread_policy;
    struct sched_param thread_param;


    pthread_attr_init(&thread_attr);
    pthread_attr_getschedpolicy(&thread_attr, &thread_policy);
    pthread_attr_getschedparam(&thread_attr, &thread_param);
    int max_priority = sched_get_priority_max(SCHED_OTHER);
    av_log(NULL, AV_LOG_INFO,"%s, %d, write thread: Default policy is %s, priority is %d, max_priority=%d\n",
        __FUNCTION__, __LINE__,
        (thread_policy == SCHED_FIFO ? "FIFO"
         : (thread_policy == SCHED_RR ? "RR"
            : (thread_policy == SCHED_OTHER ? "OTHER"
               : "unknown"))),
        thread_param.sched_priority, max_priority);
原创粉丝点击