From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9422 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: sched_* implemented? Date: Mon, 29 Feb 2016 23:59:20 -0500 Message-ID: <20160301045920.GJ9349@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1456808386 16086 80.91.229.3 (1 Mar 2016 04:59:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 1 Mar 2016 04:59:46 +0000 (UTC) Cc: musl@lists.openwall.com To: James Marshall Original-X-From: musl-return-9435-gllmg-musl=m.gmane.org@lists.openwall.com Tue Mar 01 05:59:37 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1aacPI-0006vG-6V for gllmg-musl@m.gmane.org; Tue, 01 Mar 2016 05:59:36 +0100 Original-Received: (qmail 10237 invoked by uid 550); 1 Mar 2016 04:59:34 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 10216 invoked from network); 1 Mar 2016 04:59:33 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:9422 Archived-At: On Mon, Feb 29, 2016 at 11:32:34PM -0500, James Marshall wrote: > Hi, > > I'm working on a realtime application and am trying to use musl. I would > like to call sched_setscheduler, but it looks like this is just a stub in > musl. > > However, > http://nsz.repo.hu/git/?p=musl-tables;a=blob_plain;f=tab_posix.html;hb=HEAD > has it marked as implemented. Am I missing something? Is there a patch > available? > > If there is not, any idea of how difficult it would be for me to add it in? > Or would I be better off using syscall directly instead? > > Your help and time is appreciated. The reason it doesn't do anything is that Linux does not provide a way to set scheduling parameters for a _process_, only for threads. The sched_setscheduler syscall is documented as taking a pid but actually takes a thread id and only operates on that thread. glibc just ignores this and provides sched_* functions that do the wrong thing. Fortunately there's an easy fix: use pthread_setschedparam, and pthread_self to get the pthread_t value you need to pass to it. Rich