From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 27367 invoked from network); 17 Jul 2020 05:51:18 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 17 Jul 2020 05:51:18 -0000 Received: (qmail 8008 invoked by uid 550); 17 Jul 2020 05:51:15 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 7978 invoked from network); 17 Jul 2020 05:51:15 -0000 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yqxmail.com; s=dkim; t=1594965062; bh=MhxfGC6lr6HVv74VbXzQ+bI/pkxKJeYlASSLNj7AMQU=; h=Date:From:To:Subject:From; b=TZAHyewPw5GWNl6bTaKgrps7GHOOIeUoiUGm6q7kz4uq+T2CxP4QJ6PsQ1pVLk4fI yB8NbT3MsRZOIVLC+ti3ufGR1Zz6xEPBdMsb2BvF9DJh/FWAh/0BSXhP1Ec9NJZA5b gTQEJVQ12UuFqUV5yqZ+/AfFIT8/XgUZApuH/SyWecWNfKNyl/bI+g1HZJ5Ww9I9bC +FtTdm2X1LZH3qBSk0RNPLRS7AV35SbKDlf0eCwoc+Gn727xuL3q0DAqf4AuGbcWyO FQvMyu+EwDjiX8pEU2VPTTdZutmsjg3EfHjQY7yemBp2UaVuBmfUTvwVJu+yxzyzDk yZlZxvEA6xBRQ== Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 16 Jul 2020 22:51:02 -0700 From: Hydro Flask To: musl@lists.openwall.com Message-ID: <04c05d65470b5c94808481eaf724cc5d@yqxmail.com> Subject: [musl] Idea: futex() system call entry point Hello, I have a project that implements an API that must be AS-safe. This is a blocking API, so currently the only option I have to implement the blocking behavior is select()/read() and similar FD-based calls. Using FDs to implement synchronization is okay but if there are very many threads then FD space would get exhausted (usually max 1024 FDs). It would be nice to use pthread_cond_wait() but that is not AS-safe according to POSIX. Had the idea of using futex() but my other constraint is that the blocking call must also be a cancellation point. Currently calling the futex system call through syscall() won't work and there is no way to implement cancellation on top of syscall() in a portable way since cancellation is implementation defined. So what if Linux libcs (and potentially others) started exposing futex() directly as a function call? It would need these properties to be useful: * AS-safe * cancellation point I saw that Rich Felker already proposed this many years ago but it seems it never came to fruition: https://sourceware.org/bugzilla/show_bug.cgi?id=9712#c8 What do you think about my idea? Hydro