提交 2bf2c821 编写于 作者: M manjaro-xfce

解决Linux下进程优先级配置问题

上级 984ab797
......@@ -18,14 +18,14 @@
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;
const int pnice_idle = PRIO_MAX;
const int pnice_realtime = PRIO_MIN;
const int pnice_norm = 0;
#endif
......@@ -56,7 +56,7 @@ namespace TASKBUS {
#ifdef linux
Q_PID id = p->pid();
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 +82,7 @@ namespace TASKBUS {
#ifdef linux
Q_PID 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
......@@ -190,7 +190,7 @@ namespace TASKBUS {
info->pid = p;
}
//printf( "%s (Process ID: %u)\n", szProcessName, processID );
//printf( "%s (ProcePRIO_MAXss ID: %u)\n", szProcessName, processID );
CloseHandle( hProcess );
if (info->pid==0)
......
......@@ -22,8 +22,8 @@ namespace TASKBUS {
bool get_memory (qint64 p ,tagMemoryInfo * info);
extern const int pnice_min;
extern const int pnice_max;
extern const int pnice_idle;
extern const int pnice_realtime;
extern const int pnice_norm;
}
......
......@@ -773,9 +773,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);
......@@ -790,9 +800,21 @@ 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;
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);
}
project()->set_nice(node,nic);
}
ui->graphicsView_main->scale(0.5,1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册