UbuntuのQtCreatorのWidgetアプリケーションのプログラム環境です。
下記の『set_realtime_priority()』を実行しますが、
コード『ret = pthread_setschedparam(this_thread, SCHED_FIFO, ¶ms);』の実行が成功しません。
つまりret=!0です。
Q1)ここプログラムの環境では、priorityの設定は、出来ないでしょうか?
void MainWindow::set_realtime_priority(){
// struct sched_param is used to store the scheduling priority
struct sched_param params;
int ret;
// We'll operate on the currently running thread.
pthread_t this_thread = pthread_self();
// We'll set the priority to the maximum. params.sched_priority = sched_get_priority_max(SCHED_FIFO); qDebug("Trying to set thread realtime prio=%d ",params.sched_priority); // Attempt to set thread real-time priority to the SCHED_FIFO policy ret = pthread_setschedparam(this_thread, SCHED_FIFO, ¶ms); //ret = pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶ms); if(ret!=0){ // Print the error qDebug("%s","Unsuccessful in setting thread realtime prio"); return; } // Now verify the change in thread priority int policy = 0; ret = pthread_getschedparam(this_thread, &policy, ¶ms); if (ret != 0) { qDebug("%s","Couldn't retrieve real-time scheduling paramers"); return; } // Check the correct policy was applied if(policy != SCHED_FIFO) { qDebug("%s","Scheduling is NOT SCHED_FIFO!"); } else { qDebug("%s","SCHED_FIFO OK"); } // Print thread scheduling priority qDebug("Thread priority=%d ",params.sched_priority);
}
C/C++のプログラム(main(intargc, char*argv[]))を実行する場合は
sudoをつけて実行しますが(sudo ./a.out)、QtCreatorのデバッグの場合は
これに替わる設定、方法はありますか?
以上、コメント頂けますと大変ありがたいです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。