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 19:27:41 +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=8GcL6oHbOVm7yNg/53WhmQzF2lnhspfFI8tjr/ilml8=; b=Yo0WZUqPMco+Qy3xjSajzT1R5cfrl912BzQL2vdT7COYPszjHynx9+QpJDSbhaPpSY1qsmUp5XpXtNC6jfmUAkiqfWsz45MnlyMWJup41v+hsKxCSINXoy1dtgHCvOxOYnOoHs7rk1dm+7JW40En77srwVWl8+K4P11IImarSjNDx/2IMcF4hfIQSyNlOyU93et2mp6jM5DmTd8kKN6wNTvYznQkuPhqKjukrd9opj9F9bgpzPHbnl9S6rwPVlpZs750rbbLbfNlnXkCGvdAlUom8jceUyb5vGGaf3IYYesSV2GPgisIWOb6ExH5/Oi6BBnBivHCF2P8J5WN03IGWw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aff1Kggwdi8nA9D6hMLzBn2T/Bw9iE2eQbnKj0KYiLkopGATqxJXksBhnzmnSV4VsXxjKchtJC4nCHDEmqVDWFRtV1QIc3HKEU1nd6UCeSlco5Ufr4Pup6LApTrsSHL0WrhPjUKp4vdKj/ABTjIzmaSj5YKGMg1KalVkmgJukNVBAp9zQZfLRuA6B0ft2gHMlv+DYXCIUcqA4QwyyyhxLqUSonx5dYFuNU8AmrhxYZN7V+CK5+gaEuW/Uw1PSLAJbMP9oLNP5f6cWioBIzb/vqy2G4VgjlyiaELya3x65Lipsxq2pqzM57CpQEXcYhcbiRRjyt5d91SrZljy5o102A==
- Ironport-sdr: G7dPoV9oS72NY5h34alLe2PEUSz8DbT+jxxwLQWHjHW5Oa2Z6eJYNNPm0qtcDL+I9qKh76A9Rx 0Xy1RsQsteS/AI1B5SCR6cEYGZG73NfruSJv00Ck3vQSa4Qz1+AzhxPO5t+l+UGfl/yPt07xtl Ld4WQAeybyGKHjlnku/P9ft9rPKbZoM2Mv4hsYc3vRs9Yu5/jEDEdexybTSuwmW33fB2B8l2Ic qbytNPcRbdGpvWDXyssFr/57/5S8/R+SHrYSRcDbYVdhPaAToECcPTZa9Hs+WKXS9Iimuz+GfW tpk=
- Reply-to: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" <lavr at ncbi dot nlm dot nih dot gov>
> Please give it a try.
diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc
index 2a06554..2305b53 100644
--- a/winsup/cygwin/fhandler_process.cc
+++ b/winsup/cygwin/fhandler_process.cc
@@ -1076,7 +1076,7 @@ format_process_stat (void *data, char *&destbuf)
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
@@ -1105,7 +1105,6 @@ format_process_stat (void *data, char *&destbuf)
HANDLE hProcess;
VM_COUNTERS vmc = { 0 };
KERNEL_USER_TIMES put = { 0 };
- PROCESS_BASIC_INFORMATION pbi = { 0 };
QUOTA_LIMITS ql = { 0 };
SYSTEM_TIMEOFDAY_INFORMATION stodi = { 0 };
@@ -1134,11 +1133,6 @@ format_process_stat (void *data, char *&destbuf)
if (!NT_SUCCESS (status))
debug_printf ("NtQueryInformationProcess(ProcessTimes): status %y",
status);
- status = NtQueryInformationProcess (hProcess, ProcessBasicInformation,
- (PVOID) &pbi, sizeof pbi, NULL);
- if (!NT_SUCCESS (status))
- debug_printf ("NtQueryInformationProcess(ProcessBasicInformation): "
- "status %y", status);
status = NtQueryInformationProcess (hProcess, ProcessQuotaLimits,
(PVOID) &ql, sizeof ql, NULL);
if (!NT_SUCCESS (status))
@@ -1159,17 +1153,11 @@ format_process_stat (void *data, char *&destbuf)
* CLOCKS_PER_SEC / NS100PERSEC;
else
start_time = (p->start_time - to_time_t (&stodi.BootTime)) * CLOCKS_PER_SEC;
- /* 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;
+ int nice = winprio_to_nice(GetPriorityClass(hProcess));
destbuf = (char *) crealloc_abort (destbuf, strlen (cmd) + 320);
return __small_sprintf (destbuf, "%d (%s) %c "
@@ -1181,7 +1169,7 @@ format_process_stat (void *data, char *&destbuf)
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,
+ 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