This is the mail archive of the
cygwin
mailing list for the Cygwin project.
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: Tue, 6 Aug 2019 18:54:08 +0000
- Subject: 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=5gERPJpqEPGWcq/kG57GvB+OnCfQkelYeNTKrziWvm0=; b=Gxoq54GXr3Swku3kUl6A5ifNNls9Ip+KWXDzr1cxvXWEsYHyq+eUQmiE8um7k9hkKIObv98/XiLhSAO6+KOYx9/8cwI9WYVD/m4HvpjekA281mQGbDp3RAdoyefaNWSJYcVfoXZnpx0D/aL67Qq1EVSBZl3Mf3Jz6Aj/V4xgqzvXj1kttWK9X7PZjQjMRJLTVJZRuZ5oYOe908wAnQ4x7SZxq9Z5/iuGy13DXQ43DKs9iU6+OaGvxAtaaU29rOrhROaDb3I31+aUaW29NBXE+eD+nVHl1oR2sL4N2gyajvnx5JNoAMi4eKd1t35Pf7zlUgXygkqot+2lRzGnyd+ZWw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hXJVAEawnv8buiYFPD9Y70H46YXoLVcLMTs7ggaFDXavj7zxaFTAZrANbHgQgnVFfSOheYKEaB/Ty/WGU9W5EueaFZ5IznMMmeoskaYaf3jdwPhtk4b1i2XSJsO8PeSNabtbinqnzOwh4fMGO8tNqjTqNX0gPbfvnlUKWwSQm8MS/fRvgoVsUb6cks383iMuF+OVDYqficxMEogFw2RgT0CAOjldWky0x4lONFbGZr46IImXen+TULMVyksPfy0oKaXKpR5GIgwJ+SFbhv9GL3MboWJLp27gPXiBQeT7BNrU/0capDT84CXjxyXsPzcEsyIfkbYv9QCA0EuGNmh6aA==
- Ironport-sdr: /ORKr5snuU3pzXrQpwfwzKKBT8gtS0V84zhfvZRcSc2x/EQyThy/JUs7DNtr1fDW8LoRHsI/Oq 1ju5ovXpwawmw2gqi/o7iNnW7zm8WyuUIW9ok2SeUu8otmmFhwOgbYvsqGK1YpO74WoLiYWOwX xiKnqhHg7jV2seb7AmeKGFJlseRhF7pYHAMzL1H0UK+KNpgqaTCruEowEJa5JtCfjndOIa6tai XicDk0rXUQL5ZlioJGGj+zSqor+AHr1LLn3mZGePJaR2OpKm3ptZUNM2RbK40UG6m4a25J6hQ4 Iq8=
- Reply-to: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" <lavr at ncbi dot nlm dot nih dot gov>
I have noticed a discrepancy between the process priority shown by "top" vs. what getpriority() returns.
I'm using the procps-based "top", so it reads the priority value from /proc/PID/stat. The value gets there via code found in "fhandler_process.cc":
/* 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;
But that's an inconsistent way of generating the value, because it is supposed to be the one that "getpriority()" returns.
Also, it looks like the higher value in "pbi.BasePriority" corresponds to a higher process priority, while Unix priority is higher when the value is less
(20 - nice, generally).
It looks like it should have been done by calling a utility function, winprio_to_nice(GetPriorityClass(CurrentProcess())), and setting up both the priority
field (as "NZERO + winprio_to_nice()") and the following "nice" field (which is currently set to permanent zero) with what winprio_to_nice() returns.
--
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