X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; q=dns; s= default; b=LZLktunMzElZa33B1zFyuaJNyIdmXK/naEm0DpdOy/vqg4IU5Wpbb gchRAff6jj7Ah/VkEaDaGyFUIG9vTUtH+SOTPZAVeG7GtRDb7GElDdsP7HWNxCkR XDuzsJxNE+hGxdrcOdiXTC2J7dCe+KMUgda94Ztjw8OAQD3wH8s9pY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; s=default; bh=MXLveg0RAPudRhe0W9IqrNwIb2o=; b=xzDM/Jivv3g52lnMpSiNgoZSqR+w 8Mq9RU27WG2BWv6wrchrgqFBY1TZ2fQmzdRAFxDvN12+5FGAcazpGD+6VFPOCmCT GYKbQtBa6CpvEet77/BTBNkH5n04HRP1wmwwKGTgTMTo2kOtMB84+VGGmpIxTHjR fkqd//oxkvpAukE= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-104.2 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: mout.kundenserver.de Date: Tue, 6 Aug 2019 22:08:37 +0200 From: Corinna Vinschen To: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" Cc: cygwin AT cygwin DOT com Subject: Re: getpriority() and top display for priority is inconsistent Message-ID: <20190806200837.GW11632@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" , cygwin AT cygwin DOT com References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hm39DdI+xc+0zcX9" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) --hm39DdI+xc+0zcX9 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Aug 6 18:54, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin wrote: > I have noticed a discrepancy between the process priority shown by > "top" vs. what getpriority() returns. >=20 > 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": >=20 > /* 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 =3D 8; /* Default value. */ else > priority =3D pbi.BasePriority; >=20 > But that's an inconsistent way of generating the value, because it is > supposed to be the one that "getpriority()" returns. >=20 > 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). >=20 > 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. You seem to have worked it out already so please send a patch in git format-patch foramt to the cygwin-patches mailing list. Thanks, Corinna --=20 Corinna Vinschen Cygwin Maintainer --hm39DdI+xc+0zcX9 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl1J3kUACgkQ9TYGna5E T6BDaw/9H3cv2ERXUrFTNAdtbm4jnoaomhua/brohJbZ7hCu2ztxvklfZDh2Q9e2 nMyHIu/ySMeJfGPjTnoe4nWju3YcvOl2rtMJbUBirTO7nIk/ZCaHiANnySO3x0UO +aXexJW4zx1/O0+dcGxuH2gRLKqfS+g3ClFQ36pLhNxy55eZbIpdi71wCTXB+znS 0bVc9e2qZ8xuuPjbBrB/yPusVodsjD/xF+KIN4i3ZNi0os3olCPnqZGWhEtSTlmm ELtofCX6HT8meNo26XPZWvCy0uK2R9gC1+wRgBnhmPiUWi7SdqnuNko5bmXFoV4K zu5rApq2Sa8STf/KhnSZb2lGgv2OBRBm23fo8Y7kO6F4FyO8o+mepPoPDwFjyicP iyWlJY9YJQtNVAiJ1gQkitDEo3Z20GLYRMbzNoW9JSAXzW0Ka9qs4lqvo7YT3/rR i6m78ztiJwUhp25FBtekTC841tdvidnBnlau/z5ZbSZcn6vDhPes5kXKDU6Dku4P 0nb6FIhB4F8khBZ3K5kNE1b8lz5qsxSO1AT/Lmkl6doO31ifdHWS1M/fPpn4CkHI q2lpG3Rako5iHMw/xNgDrinp1caKH7ZTPw8sKOPHTpW7nq7bAreMixhj4xHThGa+ ffVpCOyfTgw/qMJRx6JuzXLcQHPJax8x8XZ7ousHdegGMOSbBiA= =7M1f -----END PGP SIGNATURE----- --hm39DdI+xc+0zcX9--