#include #include #include #include #include #include void test() { auto _start = std::chrono::steady_clock::now(); int arr[1000000]; for (size_t i = 0; i < 1000000; i++) { for (size_t j = 0; j < 1000; j++) { arr[i] = i; } } auto times = std::chrono::duration(std::chrono::steady_clock::now() - _start).count(); printf("times = %.2f \n", times); } int main(int argc, char *argv[]) { struct sched_param param; int maxpri; maxpri = sched_get_priority_max(SCHED_FIFO); //»ñÈ¡×î´óÖµ if (maxpri == -1) { printf("sched_get_priority_max() failed \n"); exit(1); } printf("%d \n", maxpri); param.sched_priority = maxpri; std::thread threadaa(test); // if (sched_setscheduler(getpid(), SCHED_FIFO, ¶m) == -1) //设置优先级 // { // printf("sched_setscheduler() failed \n"); // exit(1); // } // if(pthread_setschedparam(threadaa.native_handle(),SCHED_FIFO,¶m)) // { // printf("sched_setscheduler() failed \n"); // exit(1); // } threadaa.join(); return 0; }