From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: * X-Spam-Status: No, score=1.1 required=3.0 tests=BAYES_00,FROM_SUSPICIOUS_NTLD, FROM_SUSPICIOUS_NTLD_FP,PDS_OTHER_BAD_TLD autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!VcP7hXO8HFaKf0JrsXChOA.user.46.165.242.75.POSTED!not-for-mail From: Fernando Oleo Blanco Newsgroups: comp.lang.ada Subject: Re: Help: Ada in NetBSD Date: Thu, 23 Sep 2021 21:53:47 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <646f270d-0e65-46a5-b40a-02afab608f1en@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: gioia.aioe.org; logging-data="26702"; posting-host="VcP7hXO8HFaKf0JrsXChOA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.1 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:62831 List-Id: Okay, so another short blog post. This is going to be a bit of a fucking rant. So... remember when I said that NetBSD expected a priority value of -1 when using SCHED_ODER? And that that was not POSIX compilant? Well, after a nice conversation in #netbsd, it has been decided to escalate this matter into a PR/ML discussion. All that good :) But the question on how does Linux work then? Remained... So I ran the ACATS suite with debugging symbols, recompilation and assertions to check. And guess what? Let the code speak: else Param.sched_priority := 0; Result := pthread_setschedparam (T.Common.LL.Thread, SCHED_OTHER, Param'Access); end if; pragma Assert (Result in 0 | EPERM | EINVAL); end Set_Priority; So the Set_Priority function receives the Default_Priority value, which I think was 48. But when it goes into the actual branch, it knows that that default value is stupid and discards it (sets it to 0). That would be all nice and dandy, but here is the problem, 0 is a valid value because most OS/arches use it, there is no reason 0 is valid (as per POSIX). And what really gets me is that Pragma... Whomever wrote it probably was getting errors and decided that that was fine. EPERM? EINVAL? Not my problem! No wonder there is a specific s-taprop__linux.adb... So here we are. NetBSD is not POSIX compliant (min and max SCHED_OTHER priority is -1, which is an error code for the function that should return it), and Linux hardcodes it. Amazing, just amazing... My solution? Email the NetBSD people. But that won't be enough. So I am thinking in patching the s-taprop__posix.adb file to try it with the default priority, if it fails, with 0, if it fails, with -1 for NetBSD... Oh well... I thought that the state of GNAT was better... Anyhow, regards, -- Fernando Oleo Blanco https://irvise.xyz