From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 59019 invoked by alias); 11 Nov 2016 11:56:17 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 58890 invoked by uid 89); 11 Nov 2016 11:56:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: Yes, score=5.6 required=5.0 tests=AWL,BAYES_40,FOREIGN_BODY,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=huber, Huber, H*x:zclient, H*UA:zclient X-HELO: dedi548.your-server.de Received: from dedi548.your-server.de (HELO dedi548.your-server.de) (85.10.215.148) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Nov 2016 11:56:05 +0000 Received: from [88.198.220.131] (helo=sslproxy02.your-server.de) by dedi548.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.85_2) (envelope-from ) id 1c5AR9-00021y-A9; Fri, 11 Nov 2016 12:56:03 +0100 Received: from [82.135.62.35] (helo=mail.embedded-brains.de) by sslproxy02.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.84_2) (envelope-from ) id 1c5AR9-0007lJ-0R; Fri, 11 Nov 2016 12:56:03 +0100 Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 599192A0003; Fri, 11 Nov 2016 12:56:15 +0100 (CET) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id GRAC5YrWYGkW; Fri, 11 Nov 2016 12:56:13 +0100 (CET) Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 309F92A1808; Fri, 11 Nov 2016 12:56:13 +0100 (CET) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id AWTZoo5NsrI2; Fri, 11 Nov 2016 12:56:13 +0100 (CET) Received: from zimbra.eb.localhost (zimbra.eb.localhost [192.168.96.204]) by mail.embedded-brains.de (Postfix) with ESMTP id 181792A0003; Fri, 11 Nov 2016 12:56:13 +0100 (CET) Date: Fri, 11 Nov 2016 11:56:00 -0000 From: Sebastian Huber To: Thomas Preudhomme Cc: newlib@sourceware.org Message-ID: <707976084.18201.1478865372907.JavaMail.zimbra@embedded-brains.de> In-Reply-To: References: <1478792031.1254.1.camel@op.pl> <60acaa10-fb22-8655-fd67-0536fe359871@foss.arm.com> <1478809956.1322.1.camel@gmail.com> Subject: Re: [PATCH, newlib] Allow locking routine to be retargeted MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016/txt/msg01092.txt.bz2 ----- Thomas Preudhomme schrieb: > On 10/11/16 20:32, Freddie Chopin wrote: [...] > > This could work, if only malloc() was not protected with the statically > > created _LOCK_T lock itself, which would need such initialization > > too... I don't see any other way to write such function for an RTOS > > which has mutexes with size greater than "uintptr_t" (probably huge > > majority). You could do it with a static pool of storage for mutexes, > > but then you'd have to know upfront how many you want and your RTOS > > would have to allow creation of locks in provided storage (most of them > > allow that, but not all). Maybe I just don't see the simplest solution > > to this problem? >=20 > Why do mutex needs to be more than a single integer? How big are mutex in= RTOS=20 > typically in your experience? This depends on what features the RTOS wants to support. For example SMP, = locking protocols, blocking on a wait queue, user-provided or external-prov= ided storage, nesting, etc. For RTEMS a recursive mutex with support for priority inheritance (or OMIP)= and SMP (optional) needs 20 bytes on a 32-bit machine for example: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;a=3Dblob;f=3Dne= wlib/libc/sys/rtems/include/sys/lock.h;h=3De0d77cb614b348a949e23ca4c543b1ce= 6a055b6d;hb=3DHEAD#l55 With an integer only you can implement a futex like on Linux, however, this= needs a complex infrastructure in the background and provides only random = fairness. --=20 Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.huber at embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine gesch=C3=A4ftliche Mitteilung im Sinne des EHUG.