This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: getpriority() and top display for priority is inconsistent
- From: "Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin" <cygwin at cygwin dot com>
- To: "'cygwin at cygwin dot com'" <cygwin at cygwin dot com>
- Date: Wed, 7 Aug 2019 00:45:20 +0000
- Subject: Re: getpriority() and top display for priority is inconsistent
- Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=ncbi.nlm.nih.gov;dmarc=pass action=none header.from=ncbi.nlm.nih.gov;dkim=pass header.d=ncbi.nlm.nih.gov;arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wHPaKb2JtufRRHM5jr47L4yA4YwBLRZ8wCz8VEDJ6zs=; b=ZT8RdAOJN2mLe0Lpb4CHWg8XHT2KH1F2UzoU+0xjJK31xukAwhb34iCWAvfsg0oL/lWiBaJRv7LMVGSSaLXhIKKfSa581dgkPoLWVehf+dpouFupsuzU1W/kkMPoPPNp2uWo5KSoizqhNa+fcWRua5fiVxjwcrGNbBZ8l8dSyCtmuHZebi4h8tWcmf9UOiMW+pgsrP9yVXZxeoJvDpzm3TbzvVnnSPnyf8JH24rV8T27ZFBxMxEDAfB4HuwjSax5tYRqF4yN/8FTZjVRojUpotxaMxytmu4FyT0KJUzwK7na4DzUcbuAiSrLuXtQoZ55vEyf/+vaHPbSHwnoNhLdEg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SYr8pF/uRtPNOQqgL+UPDMS1YNakluAdIDu1d4jg2zICF2gqP0W+mXLL40YEMIUJ++PaF2ul83VY4rvKIvHNUGIzYoEjFCIoYYLOdj384IKUPVSwaEEHfuSs14DJ8+Jr2Qrxy/aj5me0lmmLys+HaSS5k+A0ixI7AK/VgcxVh0QOqNeoQrhCsVD4Q6ESWo6CPJde1W+C5M+7nKxsiHjhQsqSSrOglSmxjtGqbgiW0TgvezR8HzCmMpbayrMbMphfIUbalMNabhDAnkzW1TqnsQyOlP6VOB6nY4MnSkXK1X96VCkH7vb0Sfo07VTrz09z8mrkTQsJTKFAmQyGHvjwzw==
- Ironport-sdr: WYTd340FfrzKtZ19/T2rkufmVNKxs/a+W4kVHpnAeugIF3bemJQSZWl5CL2W+Doz/OVVTsK1k8 rYpke3lixAlA==
- Reply-to: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" <lavr at ncbi dot nlm dot nih dot gov>
> You seem to have worked it out already so please send a patch in
> git format-patch foramt to the cygwin-patches mailing list.
I tried :-/
<cygwin-patches@cygwin.com>:
Sorry, only subscribers may post. (#5.7.2)
I do not use git to pull Cygwin sources. The last snapshot (that corresponds to the last-known-stable release I'm allowed to use) is a little old,
but here goes the diff patch:
$ diff -p cygwin-snapshot-20181226-{0,1}/winsup/cygwin/fhandler_process.cc
*** cygwin-snapshot-20181226-0/winsup/cygwin/fhandler_process.cc 2018-08-17 14:41:04.000000000 -0400
--- cygwin-snapshot-20181226-1/winsup/cygwin/fhandler_process.cc 2019-08-06 17:05:35.421073900 -0400
*************** format_process_stat (void *data, char *&
*** 1066,1072 ****
unsigned long fault_count = 0UL,
vmsize = 0UL, vmrss = 0UL, vmmaxrss = 0UL;
uint64_t utime = 0ULL, stime = 0ULL, start_time = 0ULL;
! int priority = 0;
if (p->process_state & PID_EXITED)
strcpy (cmd, "<defunct>");
else
--- 1066,1072 ----
unsigned long fault_count = 0UL,
vmsize = 0UL, vmrss = 0UL, vmmaxrss = 0UL;
uint64_t utime = 0ULL, stime = 0ULL, start_time = 0ULL;
!
if (p->process_state & PID_EXITED)
strcpy (cmd, "<defunct>");
else
*************** format_process_stat (void *data, char *&
*** 1095,1101 ****
HANDLE hProcess;
VM_COUNTERS vmc;
KERNEL_USER_TIMES put;
- PROCESS_BASIC_INFORMATION pbi;
QUOTA_LIMITS ql;
SYSTEM_TIMEOFDAY_INFORMATION stodi;
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION spt;
--- 1095,1100 ----
*************** format_process_stat (void *data, char *&
*** 1115,1123 ****
status = NtQueryInformationProcess (hProcess, ProcessTimes,
(PVOID) &put, sizeof put, NULL);
if (NT_SUCCESS (status))
- status = NtQueryInformationProcess (hProcess, ProcessBasicInformation,
- (PVOID) &pbi, sizeof pbi, NULL);
- if (NT_SUCCESS (status))
status = NtQueryInformationProcess (hProcess, ProcessQuotaLimits,
(PVOID) &ql, sizeof ql, NULL);
CloseHandle (hProcess);
--- 1114,1119 ----
*************** format_process_stat (void *data, char *&
*** 1138,1154 ****
stime = put.KernelTime.QuadPart * CLOCKS_PER_SEC / NS100PERSEC;
start_time = (put.CreateTime.QuadPart - stodi.BootTime.QuadPart)
* CLOCKS_PER_SEC / NS100PERSEC;
- /* The BasePriority returned to a 32 bit process under WOW64 is
- apparently broken, for 32 and 64 bit target processes. 64 bit
- processes get the correct base priority, even for 32 bit processes. */
- if (wincap.is_wow64 ())
- priority = 8; /* Default value. */
- else
- priority = pbi.BasePriority;
unsigned page_size = wincap.page_size ();
vmsize = vmc.PagefileUsage;
vmrss = vmc.WorkingSetSize / page_size;
vmmaxrss = ql.MaximumWorkingSetSize / page_size;
destbuf = (char *) crealloc_abort (destbuf, strlen (cmd) + 320);
return __small_sprintf (destbuf, "%d (%s) %c "
--- 1134,1144 ----
stime = put.KernelTime.QuadPart * CLOCKS_PER_SEC / NS100PERSEC;
start_time = (put.CreateTime.QuadPart - stodi.BootTime.QuadPart)
* CLOCKS_PER_SEC / NS100PERSEC;
unsigned page_size = wincap.page_size ();
vmsize = vmc.PagefileUsage;
vmrss = vmc.WorkingSetSize / page_size;
vmmaxrss = ql.MaximumWorkingSetSize / page_size;
+ int nice = winprio_to_nice(GetPriorityClass(hProcess));
destbuf = (char *) crealloc_abort (destbuf, strlen (cmd) + 320);
return __small_sprintf (destbuf, "%d (%s) %c "
*************** format_process_stat (void *data, char *&
*** 1160,1166 ****
p->pid, cmd, state,
p->ppid, p->pgid, p->sid, p->ctty, -1,
0, fault_count, fault_count, 0, 0, utime, stime,
! utime, stime, priority, 0, 0, 0,
start_time, vmsize,
vmrss, vmmaxrss
);
--- 1150,1156 ----
p->pid, cmd, state,
p->ppid, p->pgid, p->sid, p->ctty, -1,
0, fault_count, fault_count, 0, 0, utime, stime,
! utime, stime, NZERO + nice, nice, 0, 0,
start_time, vmsize,
vmrss, vmmaxrss
);
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple