提交 2019aaeb 编写于 作者: M manjaro-xfce

优化Linux进程优先级设置

上级 9354a00e
......@@ -18,14 +18,15 @@
namespace TASKBUS {
#ifdef WIN32
const int pnice_min = 0;
const int pnice_max = 5;
const int pnice_idle = 0;
const int pnice_realtime = 5;
const int pnice_norm = 2;
#endif
#ifdef linux
const int pnice_min = PRIO_MIN;
const int pnice_max = PRIO_MAX;
//in Linux, nice = -20 means realtime
const int pnice_idle = PRIO_MAX;
const int pnice_realtime = PRIO_MIN;
const int pnice_norm = 0;
#endif
......@@ -56,7 +57,7 @@ namespace TASKBUS {
#ifdef linux
__PID_T_TYPE id = p->processId();
if (nice<-PRIO_MIN) nice = PRIO_MIN;
if (nice<PRIO_MIN) nice = PRIO_MIN;
if (nice>PRIO_MAX) nice = PRIO_MAX;
setpriority(PRIO_PROCESS,id,nice);
#endif
......@@ -82,7 +83,7 @@ namespace TASKBUS {
#ifdef linux
__PID_T_TYPE id = getpid();
if (nice<-PRIO_MIN) nice = PRIO_MIN;
if (nice<PRIO_MIN) nice = PRIO_MIN;
if (nice>PRIO_MAX) nice = PRIO_MAX;
setpriority(PRIO_PROCESS,id,nice);
#endif
......
......@@ -22,8 +22,11 @@ namespace TASKBUS {
bool get_memory (qint64 p ,tagMemoryInfo * info);
extern const int pnice_min;
extern const int pnice_max;
//Idle Nice
extern const int pnice_idle;
//Busy Nice
extern const int pnice_realtime;
//Normal Nice
extern const int pnice_norm;
}
......
......@@ -772,9 +772,19 @@ void PDesignerView::on_actionNiceUp_triggered()
if (node>=0 && node < sz)
{
int nic = project()->get_nice(node);
++nic;
if (nic>TASKBUS::pnice_max)
nic = TASKBUS::pnice_max;
if (TASKBUS::pnice_realtime < TASKBUS::pnice_idle)
{
--nic;
if (nic<TASKBUS::pnice_realtime)
nic = TASKBUS::pnice_realtime;
}
else
{
++nic;
if (nic>TASKBUS::pnice_realtime)
nic = TASKBUS::pnice_realtime;
}
project()->set_nice(node,nic);
}
ui->graphicsView_main->scale(0.5,1);
......@@ -789,10 +799,22 @@ void PDesignerView::on_actionNiceDown_triggered()
if (node>=0 && node < sz)
{
int nic = project()->get_nice(node);
--nic;
if (nic<TASKBUS::pnice_min)
nic = TASKBUS::pnice_min;
project()->set_nice(node,nic);
if (TASKBUS::pnice_realtime < TASKBUS::pnice_idle)
{
++nic;
if (nic>TASKBUS::pnice_idle)
nic = TASKBUS::pnice_idle;
project()->set_nice(node,nic);
}
else
{
--nic;
if (nic<TASKBUS::pnice_idle)
nic = TASKBUS::pnice_idle;
project()->set_nice(node,nic);
}
}
ui->graphicsView_main->scale(0.5,1);
ui->graphicsView_main->scale(2,1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册