Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 17 May 2023 17:17:28 +0600
From: NRK <>
Subject: Re: Question:Why musl call a_barrier in __pthread_once?

On Wed, May 17, 2023 at 06:07:09PM +0800, 847567161 wrote:
> Why musl add&nbsp;a_barrier() in if branch here?

It's explained in the comment:

| but ensure that effects of the init routine are visible to the caller.

> What happend if we remove it? Could you give me more details?

If you remove the barrier, then the calling code may not see the effects
of the init function, especially on cpus with "relaxed" memory ordering.

Which leads me to the question, are you familiar with cpu memory
ordering? If not, I'd recommend reading this:

One more thing, what's the motivation behind trying to remove the
barrier in the first place?


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.