From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-2.4 required=3.0 tests=AWL,BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 31EB71F85E for ; Fri, 13 Jul 2018 13:18:58 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=wGi8w3ZQ0bqHWdRI GOxgBZCtYTBKsqaGF2WogKsJoHPV/D1CPpAuLFmFKTZYHUhdSWH083AW0iWfELL6 9Gif0aoRiDtCGssIKR1e445hNRvs2iKTx4QpiQsgmCoTaQqZ0ZmTGYs9gTRiptgj uJWWBgJr/C64qSAW6Y60tNnYMNc= 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:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=r0NZRkadWMSkUZvoPPwPz9 9XfYA=; b=CHk+HwfiEaeXx/vVjAPxR1vBzUHM/gNA+qlZEsvjfbAuK8m6gnPGcJ Bn2FSdETGCyYz/iIdBj3KWRezSzRONMmnn+/ENsaU61vfyGRn2XYr4Gf+rOK096k LEJMkShIln4Lap6rXNiwVJTn6snbkGGs40P4wUIB0dZ4eH+rEQ/AI= Received: (qmail 36084 invoked by alias); 13 Jul 2018 13:18:55 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 36038 invoked by uid 89); 13 Jul 2018 13:18:54 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-vk0-f66.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=2j9UN8dTH0O9ENsfqAPeaEZj0trVROPMh4Y0/gAaPE0=; b=RYOXlTeEN8Ls5L7f802wDX8r+gWhlOUILKUXdMSSeru7NU9uXLAONeilGHzkBX2fDK Rl/eMihy2akoDiJko5xsUY4p8TBFLpWdD4V32tuowPv3evQYU3k9fo3CCnoBb9YImqEI /kZ8/v+5s8Ye6Xza0F+U1ac5miRa1tcpbbFGw= Subject: Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions To: Florian Weimer , libc-alpha@sourceware.org References: <1517591084-11347-1-git-send-email-adhemerval.zanella@linaro.org> <1517591084-11347-2-git-send-email-adhemerval.zanella@linaro.org> <6bd3db7f-6fb5-8951-edc1-507fa93cb31a@redhat.com> <0ebcfb95-926d-b7a1-b762-7388f1e2b5d1@redhat.com> From: Adhemerval Zanella Openpgp: preference=signencrypt Message-ID: <38895177-c89b-40ae-9dbd-53768d3d73be@linaro.org> Date: Fri, 13 Jul 2018 10:18:47 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <0ebcfb95-926d-b7a1-b762-7388f1e2b5d1@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 13/07/2018 10:04, Florian Weimer wrote: > On 07/13/2018 02:59 PM, Adhemerval Zanella wrote: >> >> >> On 13/07/2018 06:45, Florian Weimer wrote: >>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote: >>>>     2. thrd_sleep uses nanosleep internal direct syscall to avoid clobbering >>>>        errno, to handle expected standard return codes, and to avoid making >>>>        the call a POSIX cancellation entrypoint. >>> >>> Isn't this inconsistent with the conditional variable wait and thread join functions, which are still cancellation points? >>> >>> On the other hand, a sleep function which is not a cancellation point may be useful. >> >> I am not sure which would be the best option to handle POSIX cancellation >> with C11 threads with nptl implementation. Most straightforward option is >> just use cancellation entrypoints as default, even though using thread >> cancellation in C11 is UB (there is no defined way the use can get the >> POSIX thread id from a C11 thread). > > That's not true.  The POSIX thread ID is available using pthread_self on the thread itself, and that can be passed to another thread. That is what I am not sure, if mixing POSIX semantic with C11 is really defined by any standard (for instance, calling pthread_cancel with an POSIX thread ID which was not created by pthread_create). > >> Another option is just disable cancellation by using non-cancellable >> entry-points and/or explicit disable cancellation.  For thrd_join is >> just a matter to set on '__pthread_timedjoin_ex', but for >> cnd_wait/cnd_timedwait we either need to explicit enable/disable or >> add an option to __pthread_cond_wait_common to select whether to use >> cancellable syscalls. > > From my point of view, the least surprising approach would be to make thrd_sleep a cancellation point to match nanosleep. Right, I will change thrd_sleep to use a cancellation entrypoint. We can evaluate the POSIX cancellation interaction with C11 threads in next releases.