From: Sebastian Huber <sebastian.huber@embedded-brains.de>
To: Thomas Preudhomme <thomas.preudhomme@foss.arm.com>,
newlib@sourceware.org
Subject: Re: [PATCH, newlib] Allow locking routine to be retargeted
Date: Fri, 25 Nov 2016 12:35:00 -0000 [thread overview]
Message-ID: <5838300D.6090000@embedded-brains.de> (raw)
In-Reply-To: <0860238c-628a-8af9-5135-cf0cb84cbe30@foss.arm.com>
On 25/11/16 13:04, Thomas Preudhomme wrote:
>
>
> On 25/11/16 10:21, Thomas Preudhomme wrote:
>>
>>
>> On 24/11/16 07:44, Sebastian Huber wrote:
>>> Hello Thomas,
>>>
>>> On 23/11/16 15:38, Thomas Preudhomme wrote:
>>>> Hi Sebastian,
>>>>
>>>> I was thinking on how to solve this issue and found two possible
>>>> solutions:
>>>>
>>>> 1) select size of lock at configure time
>>>>
>>>> Instead of being an enable/disable option the configure option
>>>> could take an
>>>> integer value N that determine the size of lock, default being the
>>>> size of a
>>>> pointer. The lock would then be defined as an array of N integers.
>>>>
>>>> Pro: LOCK_INIT works, simpler & smaller change
>>>> Cons: lock needs to be as big as the biggest lock among all the
>>>> platforms you
>>>> want to target wasting a bit of space.
>>>>
>>>> 2) Remove static initialization of locks
>>>>
>>>> Remove all LOCK_INIT and add code as required to call
>>>> lock_initialize at start
>>>> up time.
>>>>
>>>> Pro: you only pay the size for the lock you need (ie nothing except
>>>> empty
>>>> functions in the single threaded case)
>>>> Cons: much bigger work, start up cannot support multithread
>>>
>>> 3)
>>>
>>> struct _lock;
>>>
>>> typedef struct _lock *_LOCK_T;
>>>
>>> #define __LOCK_INIT(class, lock) extern struct _lock _lock_ ## lock;
>>> class
>>> _LOCK_T lock = &_lock_ ## lock;
>>>
>>> The OS must then provide struct _lock and storage for all statically
>>> initialized
>>> locks.
>>
>> Oh nice, clever. I've check whether there is name collision in the
>> source where
>> this would lead them to use the same lock and found:
>>
>> newlib/libc/sys/linux/iconv/gconv_db.c: __LOCK_INIT(static, lock);
>> newlib/libc/sys/linux/iconv/gconv_trans.c: __LOCK_INIT(static, lock);
>>
>> The one thing I worry is the risk of new lock being added with the
>> same name.
>> Fortunately this could be detected at link time by looking for
>> relocation to
>> "_lock_.*" in newlib library and check that there is no duplicate.
>
> One issue though, this means the OS needs to be updated each time a
> statically initialized lock is added to newlib. That seems to be a bit
> too much coupling. Or am I misunderstanding how this should be used?
Yes, but how many locks per minute are added to Newlib?
--
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@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
next prev parent reply other threads:[~2016-11-25 12:35 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-10 14:42 Thomas Preudhomme
2016-11-10 15:34 ` Freddie Chopin
2016-11-10 16:05 ` Thomas Preudhomme
2016-11-10 20:32 ` Freddie Chopin
2016-11-10 20:35 ` Freddie Chopin
2016-11-11 9:38 ` AW: " onkel.jack
2016-11-11 11:01 ` Thomas Preudhomme
2016-11-11 11:20 ` onkel.jack
2016-11-11 12:13 ` Freddie Chopin
2016-11-11 11:09 ` Thomas Preudhomme
2016-11-11 11:54 ` Freddie Chopin
2016-11-11 11:56 ` Sebastian Huber
2016-11-11 13:40 ` Thomas Preudhomme
2016-11-11 14:10 ` Freddie Chopin
2016-11-23 14:38 ` Thomas Preudhomme
2016-11-23 15:52 ` Freddie Chopin
2016-11-24 7:44 ` Sebastian Huber
2016-11-24 8:29 ` Freddie Chopin
2016-11-25 10:21 ` Thomas Preudhomme
2016-11-25 12:04 ` Thomas Preudhomme
2016-11-25 12:35 ` Sebastian Huber [this message]
2016-12-13 17:20 ` Thomas Preudhomme
2016-11-25 14:12 ` Freddie Chopin
2016-12-13 17:18 Thomas Preudhomme
2016-12-13 20:13 ` Freddie Chopin
2016-12-14 11:54 ` Thomas Preudhomme
2016-12-14 12:39 ` Freddie Chopin
2017-01-11 13:09 ` Thomas Preudhomme
2016-12-13 21:11 ` Freddie Chopin
2016-12-13 21:41 ` Freddie Chopin
2016-12-14 14:22 ` Sebastian Huber
2016-12-14 14:36 ` Thomas Preudhomme
2016-12-14 14:52 ` Thomas Preudhomme
2017-01-09 18:49 ` Freddie Chopin
2017-01-10 16:50 ` Thomas Preudhomme
2017-01-10 17:07 ` Freddie Chopin
2017-01-11 16:09 ` Thomas Preudhomme
2017-01-11 16:46 ` Craig Howland
2017-01-11 17:48 ` Thomas Preudhomme
2017-01-11 18:08 ` Craig Howland
2017-01-11 19:14 ` Freddie Chopin
2017-01-12 10:52 ` Thomas Preudhomme
2017-01-12 16:20 ` Freddie Chopin
2017-01-12 16:55 ` Thomas Preudhomme
2017-01-13 11:25 ` Thomas Preudhomme
2017-01-13 13:24 ` Thomas Preudhomme
2017-01-13 18:05 ` Freddie Chopin
2017-01-13 18:16 ` Thomas Preudhomme
2017-01-16 15:59 ` Thomas Preudhomme
2017-01-20 13:37 ` Thomas Preudhomme
2017-01-20 13:55 ` Freddie Chopin
2017-01-24 10:00 ` Freddie Chopin
2017-01-25 12:31 ` Corinna Vinschen
2017-01-30 10:51 ` Thomas Preudhomme
2016-12-14 15:27 ` Freddie Chopin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5838300D.6090000@embedded-brains.de \
--to=sebastian.huber@embedded-brains.de \
--cc=newlib@sourceware.org \
--cc=thomas.preudhomme@foss.arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).