Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Netscape is not a newsreader, and probably never shall be. -- Tom Christiansen


devel / comp.lang.c / Re: Advanced (for me) Question About Keyword volatile

SubjectAuthor
* Advanced (for me) Question About Keyword volatiledas...@gmail.com
+* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|`* Re: Advanced (for me) Question About Keyword volatileBonita Montero
| `* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|  `* Re: Advanced (for me) Question About Keyword volatileBonita Montero
|   `* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|    `* Re: Advanced (for me) Question About Keyword volatileBonita Montero
|     +* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|     |`* Re: Advanced (for me) Question About Keyword volatileBonita Montero
|     | `* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|     |  `* Re: Advanced (for me) Question About Keyword volatileBonita Montero
|     |   `* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|     |    `* Re: Advanced (for me) Question About Keyword volatileBonita Montero
|     |     `- Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|     `* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|      +* Re: Advanced (for me) Question About Keyword volatileBonita Montero
|      |`* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|      | `* Re: Advanced (for me) Question About Keyword volatileBonita Montero
|      |  `* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|      |   +- Re: Advanced (for me) Question About Keyword volatileBonita Montero
|      |   `* Re: Advanced (for me) Question About Keyword volatileBonita Montero
|      |    `* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|      |     `* Re: Advanced (for me) Question About Keyword volatileBonita Montero
|      |      `* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|      |       `* Re: Advanced (for me) Question About Keyword volatileBonita Montero
|      |        `* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|      |         `* Re: Advanced (for me) Question About Keyword volatileBonita Montero
|      |          `* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|      |           `* Re: Advanced (for me) Question About Keyword volatileBonita Montero
|      |            `- Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|      `* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
|       `- Re: Advanced (for me) Question About Keyword volatileBonita Montero
+* Re: Advanced (for me) Question About Keyword volatileManfred
|`- Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
+- Re: Advanced (for me) Question About Keyword volatileDavid Brown
+* Re: Advanced (for me) Question About Keyword volatileÖö Tiib
|`* Re: Advanced (for me) Question About Keyword volatileJorgen Grahn
| `- Re: Advanced (for me) Question About Keyword volatileKaz Kylheku
`* Re: Advanced (for me) Question About Keyword volatileBonita Montero
 `* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
  `* Re: Advanced (for me) Question About Keyword volatileBonita Montero
   `* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
    `* Re: Advanced (for me) Question About Keyword volatileBonita Montero
     `* Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson
      `* Re: Advanced (for me) Question About Keyword volatileBonita Montero
       `- Re: Advanced (for me) Question About Keyword volatileChris M. Thomasson

Pages:12
Re: Advanced (for me) Question About Keyword volatile

<svmtp2$b27$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20678&group=comp.lang.c#20678

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Wed, 2 Mar 2022 06:02:31 +0100
Organization: A noiseless patient Spider
Lines: 105
Message-ID: <svmtp2$b27$2@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me> <svmsfh$49c$1@dont-email.me>
<svmt1v$594$4@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Mar 2022 05:02:26 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="11335"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+x6NOsjUNP9MIM4Z6c9Lnvi6CiKHfDmys="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:2B0ufUMK19MtcKus9v16L8zoiRI=
In-Reply-To: <svmt1v$594$4@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 05:02 UTC

Am 02.03.2022 um 05:50 schrieb Chris M. Thomasson:
> On 3/1/2022 8:40 PM, Bonita Montero wrote:
>> Am 02.03.2022 um 05:29 schrieb Chris M. Thomasson:
>>> On 3/1/2022 8:12 PM, Bonita Montero wrote:
>>>> Am 02.03.2022 um 04:54 schrieb Chris M. Thomasson:
>>>>> On 3/1/2022 7:45 PM, Bonita Montero wrote:
>>>>>> Am 01.03.2022 um 22:32 schrieb Chris M. Thomasson:
>>>>>>> On 2/28/2022 11:51 PM, Bonita Montero wrote:
>>>>>>>> Am 28.02.2022 um 01:14 schrieb Chris M. Thomasson:
>>>>>>>>> On 2/27/2022 2:35 PM, das...@gmail.com wrote:
>>>>>>>>>> I have 3 variables used as interface variables between 2
>>>>>>>>>> threads. Thread A writes the variables, and Thread B reads
>>>>>>>>>> them.  Let me call them v1, v2, and v3.
>>>>>>>>>>
>>>>>>>>>> I buffer (or snapshot) them into local variables.
>>>>>>>>>>
>>>>>>>>>> Question:  Do the local variables need to be declared volatile
>>>>>>>>>> as well?
>>>>>>>>>
>>>>>>>>> The local variables are fine, and do not need to be
>>>>>>>>> atomic/volatile, ect... Btw, think about using C atomic's
>>>>>>>>> instead of volatile. You might be interested in a seqlock:
>>>>>>>>> https://en.wikipedia.org/wiki/Seqlock
>>>>>>>>> (read all)
>>>>>>>>> They are geared to a read-mostly, write rarely pattern.
>>>>>>>>
>>>>>>>> Seqlocks don't make sense in user-space as they're lock-free and
>>>>>>>> a writer, having made the seq-counter odd, may be easily scheduled
>>>>>>>> away before making the seq-counter even again.
>>>>>>>
>>>>>>> Huh? The writers use a mutex. So, how lock-free is a writer?
>>>>>>> For some reason, I don't think you have ever used one.
>>>>>>
>>>>>> Seqlocks need disabling the scheduler on a core while writing
>>>>>> that a writer can't be scheduled away. That's not possible in
>>>>>> user-mode.
>>>>>
>>>>> Huh? Wow. This basically confirms that you have never used a
>>>>> seqlock in user land. Remember that the writer uses a normal mutex.
>>>>> Now, a friend of mine created a really neat mutation of a seqlock:
>>>>
>>>> No, readers and writers spin.
>>>> Otherwise you don't have a seq-lock but sth. different.
>>>> Look how it is implemented in the Linux kernel.
>>>
>>>
>>> The basic seqlock minus the tricky membars:
>>>
>>> // quick and crude pseudo-code
>>>
>>> struct state { int a = 0; }
>>> mutex g_lock;
>>> atomic_unsigned g_ver = 0;
>>>
>>> state g_state;
>>>
>>> // writers
>>> lock(g_lock);
>>>    ++ver;
>>>
>>>      ++g_state.a;
>>>
>>>    ++ver;
>>> unlock(g_lock);
>>>
>>>
>>> // readers
>>> state lstate;
>>>
>>> for (;;)
>>> {
>>>    unsigned ver0 = g_ver;
>>>
>>>      lstate = g_state;
>>>
>>>    unsigned ver1 = g_ver;
>>>
>>>
>>>    if ((! (ver0 & 1)) && (ver0 == ver1))
>>>    {
>>>       break;
>>>    }
>>>
>>>
>>>    // A reader spun! Humm...
>>>    // yield, backoff, do something else
>>> }
>>>
>>>
>>> The pattern is read-mostly, write-rarely. Fast reads, slow writes. It
>>> works in user-land.
>>
>> Boy, you're so ultimately studpid.
>>
>> Readers could spin for a long time when whe writer is scheduled
>> away. So the approach of 1024 cores is not tolerable in userspace
>> and seqlocks only make sense in kernel space where the writer could
>> disable scheduling while spinning of modifying.
>
> A writer never spins! God damn it. LOL!

With this stupid 1024 cores implementation not.
But the Linux kernel implementation doesn't use mutexes, and the
Linux kernel implementation is the only feasible way to have seqlocks.

Re: Advanced (for me) Question About Keyword volatile

<svmtv7$cg3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20679&group=comp.lang.c#20679

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Wed, 2 Mar 2022 06:05:47 +0100
Organization: A noiseless patient Spider
Lines: 4
Message-ID: <svmtv7$cg3$1@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svkl61$vca$1@dont-email.me> <svmto3$bja$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 05:05:43 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="12803"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19VQNTf/9k1peRnLNwgY5yAYhQ7fNzZa4o="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:z/+LKiG/V/6FnhzZ75zThS0J/5U=
In-Reply-To: <svmto3$bja$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 05:05 UTC

> BAM! local_v2 just read v2 outside of the mutex protection. ...

That's not what he actually does.

Re: Advanced (for me) Question About Keyword volatile

<svmtvj$bja$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20680&group=comp.lang.c#20680

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Tue, 1 Mar 2022 21:05:55 -0800
Organization: A noiseless patient Spider
Lines: 114
Message-ID: <svmtvj$bja$3@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me> <svmsfh$49c$1@dont-email.me>
<svmt1v$594$4@dont-email.me> <svmtp2$b27$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Mar 2022 05:05:56 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d4a417dfd5e5fa43753e81c21b04ad49";
logging-data="11882"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xouRYWwXDGNglcqX00wsarEZRgSuFd3A="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:gdKhlv1sxKfhexoi2ilwGOYgx6E=
In-Reply-To: <svmtp2$b27$2@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 2 Mar 2022 05:05 UTC

On 3/1/2022 9:02 PM, Bonita Montero wrote:
> Am 02.03.2022 um 05:50 schrieb Chris M. Thomasson:
>> On 3/1/2022 8:40 PM, Bonita Montero wrote:
>>> Am 02.03.2022 um 05:29 schrieb Chris M. Thomasson:
>>>> On 3/1/2022 8:12 PM, Bonita Montero wrote:
>>>>> Am 02.03.2022 um 04:54 schrieb Chris M. Thomasson:
>>>>>> On 3/1/2022 7:45 PM, Bonita Montero wrote:
>>>>>>> Am 01.03.2022 um 22:32 schrieb Chris M. Thomasson:
>>>>>>>> On 2/28/2022 11:51 PM, Bonita Montero wrote:
>>>>>>>>> Am 28.02.2022 um 01:14 schrieb Chris M. Thomasson:
>>>>>>>>>> On 2/27/2022 2:35 PM, das...@gmail.com wrote:
>>>>>>>>>>> I have 3 variables used as interface variables between 2
>>>>>>>>>>> threads. Thread A writes the variables, and Thread B reads
>>>>>>>>>>> them.  Let me call them v1, v2, and v3.
>>>>>>>>>>>
>>>>>>>>>>> I buffer (or snapshot) them into local variables.
>>>>>>>>>>>
>>>>>>>>>>> Question:  Do the local variables need to be declared
>>>>>>>>>>> volatile as well?
>>>>>>>>>>
>>>>>>>>>> The local variables are fine, and do not need to be
>>>>>>>>>> atomic/volatile, ect... Btw, think about using C atomic's
>>>>>>>>>> instead of volatile. You might be interested in a seqlock:
>>>>>>>>>> https://en.wikipedia.org/wiki/Seqlock
>>>>>>>>>> (read all)
>>>>>>>>>> They are geared to a read-mostly, write rarely pattern.
>>>>>>>>>
>>>>>>>>> Seqlocks don't make sense in user-space as they're lock-free and
>>>>>>>>> a writer, having made the seq-counter odd, may be easily scheduled
>>>>>>>>> away before making the seq-counter even again.
>>>>>>>>
>>>>>>>> Huh? The writers use a mutex. So, how lock-free is a writer?
>>>>>>>> For some reason, I don't think you have ever used one.
>>>>>>>
>>>>>>> Seqlocks need disabling the scheduler on a core while writing
>>>>>>> that a writer can't be scheduled away. That's not possible in
>>>>>>> user-mode.
>>>>>>
>>>>>> Huh? Wow. This basically confirms that you have never used a
>>>>>> seqlock in user land. Remember that the writer uses a normal
>>>>>> mutex. Now, a friend of mine created a really neat mutation of a
>>>>>> seqlock:
>>>>>
>>>>> No, readers and writers spin.
>>>>> Otherwise you don't have a seq-lock but sth. different.
>>>>> Look how it is implemented in the Linux kernel.
>>>>
>>>>
>>>> The basic seqlock minus the tricky membars:
>>>>
>>>> // quick and crude pseudo-code
>>>>
>>>> struct state { int a = 0; }
>>>> mutex g_lock;
>>>> atomic_unsigned g_ver = 0;
>>>>
>>>> state g_state;
>>>>
>>>> // writers
>>>> lock(g_lock);
>>>>    ++ver;
>>>>
>>>>      ++g_state.a;
>>>>
>>>>    ++ver;
>>>> unlock(g_lock);
>>>>
>>>>
>>>> // readers
>>>> state lstate;
>>>>
>>>> for (;;)
>>>> {
>>>>    unsigned ver0 = g_ver;
>>>>
>>>>      lstate = g_state;
>>>>
>>>>    unsigned ver1 = g_ver;
>>>>
>>>>
>>>>    if ((! (ver0 & 1)) && (ver0 == ver1))
>>>>    {
>>>>       break;
>>>>    }
>>>>
>>>>
>>>>    // A reader spun! Humm...
>>>>    // yield, backoff, do something else
>>>> }
>>>>
>>>>
>>>> The pattern is read-mostly, write-rarely. Fast reads, slow writes.
>>>> It works in user-land.
>>>
>>> Boy, you're so ultimately studpid.
>>>
>>> Readers could spin for a long time when whe writer is scheduled
>>> away. So the approach of 1024 cores is not tolerable in userspace
>>> and seqlocks only make sense in kernel space where the writer could
>>> disable scheduling while spinning of modifying.
>>
>> A writer never spins! God damn it. LOL!
>
> With this stupid 1024 cores implementation not.

Huh? A traditional seqlock uses a lock for a writer. You really need to
calm down and read about seqlocks.

> But the Linux kernel implementation doesn't use mutexes, and the
> Linux kernel implementation is the only feasible way to have seqlocks.
>

Sigh.

Re: Advanced (for me) Question About Keyword volatile

<svmu49$d2h$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20681&group=comp.lang.c#20681

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Wed, 2 Mar 2022 06:08:29 +0100
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <svmu49$d2h$1@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me> <svmsfh$49c$1@dont-email.me>
<svmt1v$594$4@dont-email.me> <svmtp2$b27$2@dont-email.me>
<svmtvj$bja$3@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 05:08:25 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="13393"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/eHIs2FthBQqYhaqeKLUq2BYqtB0ArOUM="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:SyVLftGDDXVGhESYmjAxn0JHNSI=
In-Reply-To: <svmtvj$bja$3@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 05:08 UTC

> Huh? A traditional seqlock uses a lock for a writer. You really need to
> calm down and read about seqlocks.

"Traditional" seqlocks are what the Linux kernel implements.
And this seqlocks don't use mutexes.

Having mutexes is a bad idea because the writer could be scheduled
away and keep the readers spinning for a long time. No one wants
such stupid things in userspace.

Re: Advanced (for me) Question About Keyword volatile

<svmu68$d2h$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20682&group=comp.lang.c#20682

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Wed, 2 Mar 2022 06:09:32 +0100
Organization: A noiseless patient Spider
Lines: 118
Message-ID: <svmu68$d2h$2@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me> <svmsfh$49c$1@dont-email.me>
<svmt1v$594$4@dont-email.me> <svmtp2$b27$2@dont-email.me>
<svmtvj$bja$3@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Mar 2022 05:09:28 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="13393"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/q2HMD8EnA1/gf35yoVcjDi3EMm2E3AvY="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:oWWyT86Gj+w5SwXrHiASWQ26X8s=
In-Reply-To: <svmtvj$bja$3@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 05:09 UTC

Am 02.03.2022 um 06:05 schrieb Chris M. Thomasson:
> On 3/1/2022 9:02 PM, Bonita Montero wrote:
>> Am 02.03.2022 um 05:50 schrieb Chris M. Thomasson:
>>> On 3/1/2022 8:40 PM, Bonita Montero wrote:
>>>> Am 02.03.2022 um 05:29 schrieb Chris M. Thomasson:
>>>>> On 3/1/2022 8:12 PM, Bonita Montero wrote:
>>>>>> Am 02.03.2022 um 04:54 schrieb Chris M. Thomasson:
>>>>>>> On 3/1/2022 7:45 PM, Bonita Montero wrote:
>>>>>>>> Am 01.03.2022 um 22:32 schrieb Chris M. Thomasson:
>>>>>>>>> On 2/28/2022 11:51 PM, Bonita Montero wrote:
>>>>>>>>>> Am 28.02.2022 um 01:14 schrieb Chris M. Thomasson:
>>>>>>>>>>> On 2/27/2022 2:35 PM, das...@gmail.com wrote:
>>>>>>>>>>>> I have 3 variables used as interface variables between 2
>>>>>>>>>>>> threads. Thread A writes the variables, and Thread B reads
>>>>>>>>>>>> them.  Let me call them v1, v2, and v3.
>>>>>>>>>>>>
>>>>>>>>>>>> I buffer (or snapshot) them into local variables.
>>>>>>>>>>>>
>>>>>>>>>>>> Question:  Do the local variables need to be declared
>>>>>>>>>>>> volatile as well?
>>>>>>>>>>>
>>>>>>>>>>> The local variables are fine, and do not need to be
>>>>>>>>>>> atomic/volatile, ect... Btw, think about using C atomic's
>>>>>>>>>>> instead of volatile. You might be interested in a seqlock:
>>>>>>>>>>> https://en.wikipedia.org/wiki/Seqlock
>>>>>>>>>>> (read all)
>>>>>>>>>>> They are geared to a read-mostly, write rarely pattern.
>>>>>>>>>>
>>>>>>>>>> Seqlocks don't make sense in user-space as they're lock-free and
>>>>>>>>>> a writer, having made the seq-counter odd, may be easily
>>>>>>>>>> scheduled
>>>>>>>>>> away before making the seq-counter even again.
>>>>>>>>>
>>>>>>>>> Huh? The writers use a mutex. So, how lock-free is a writer?
>>>>>>>>> For some reason, I don't think you have ever used one.
>>>>>>>>
>>>>>>>> Seqlocks need disabling the scheduler on a core while writing
>>>>>>>> that a writer can't be scheduled away. That's not possible in
>>>>>>>> user-mode.
>>>>>>>
>>>>>>> Huh? Wow. This basically confirms that you have never used a
>>>>>>> seqlock in user land. Remember that the writer uses a normal
>>>>>>> mutex. Now, a friend of mine created a really neat mutation of a
>>>>>>> seqlock:
>>>>>>
>>>>>> No, readers and writers spin.
>>>>>> Otherwise you don't have a seq-lock but sth. different.
>>>>>> Look how it is implemented in the Linux kernel.
>>>>>
>>>>>
>>>>> The basic seqlock minus the tricky membars:
>>>>>
>>>>> // quick and crude pseudo-code
>>>>>
>>>>> struct state { int a = 0; }
>>>>> mutex g_lock;
>>>>> atomic_unsigned g_ver = 0;
>>>>>
>>>>> state g_state;
>>>>>
>>>>> // writers
>>>>> lock(g_lock);
>>>>>    ++ver;
>>>>>
>>>>>      ++g_state.a;
>>>>>
>>>>>    ++ver;
>>>>> unlock(g_lock);
>>>>>
>>>>>
>>>>> // readers
>>>>> state lstate;
>>>>>
>>>>> for (;;)
>>>>> {
>>>>>    unsigned ver0 = g_ver;
>>>>>
>>>>>      lstate = g_state;
>>>>>
>>>>>    unsigned ver1 = g_ver;
>>>>>
>>>>>
>>>>>    if ((! (ver0 & 1)) && (ver0 == ver1))
>>>>>    {
>>>>>       break;
>>>>>    }
>>>>>
>>>>>
>>>>>    // A reader spun! Humm...
>>>>>    // yield, backoff, do something else
>>>>> }
>>>>>
>>>>>
>>>>> The pattern is read-mostly, write-rarely. Fast reads, slow writes.
>>>>> It works in user-land.
>>>>
>>>> Boy, you're so ultimately studpid.
>>>>
>>>> Readers could spin for a long time when whe writer is scheduled
>>>> away. So the approach of 1024 cores is not tolerable in userspace
>>>> and seqlocks only make sense in kernel space where the writer could
>>>> disable scheduling while spinning of modifying.
>>>
>>> A writer never spins! God damn it. LOL!
>>
>> With this stupid 1024 cores implementation not.
>
> Huh? A traditional seqlock uses a lock for a writer. You really need to
> calm down and read about seqlocks.

That's linux seqlock-structure:

typedef struct {
struct seqcount seqcount;
spinlock_t lock;
} seqlock_t;

Where's the mutex ?

Re: Advanced (for me) Question About Keyword volatile

<svmu6m$e3q$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20683&group=comp.lang.c#20683

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Tue, 1 Mar 2022 21:09:39 -0800
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <svmu6m$e3q$1@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svkl61$vca$1@dont-email.me> <svmto3$bja$1@dont-email.me>
<svmtv7$cg3$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 05:09:42 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d4a417dfd5e5fa43753e81c21b04ad49";
logging-data="14458"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19TWW6X10C9n39+j2dxNBxc2NMALn4JJF0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:vKskY8vQq/V565WvEtTDUcidyOc=
In-Reply-To: <svmtv7$cg3$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 2 Mar 2022 05:09 UTC

On 3/1/2022 9:05 PM, Bonita Montero wrote:
>> BAM! local_v2 just read v2 outside of the mutex protection. ...
>
> That's not what he actually does.
>

Oh yes he does! Calm down and read it again.

ThreadA:

A[0] MUTEX_BEGIN();
A[1] v1 = expression1;
A[2] MUTEX_END();
...
A[3] MUTEX_BEGIN();
A[4] v2 = expression2;
A[5] MUTEX_END();
...
A[6] MUTEX_BEGIN();
A[7] v3 = expression3;
A[8] MUTEX_END();

ThreadB:

B[0] MUTEX_BEGIN();
B[1] buf_v1 = v1;
B[2] buf_v2 = v2;
B[3] buf_v3 = v3;
B[4] MUTEX_END();

The following sequence requires atomics:

A[0]
A[1]
A[2]
B[0]
B[1]
B[2] BAM! we just read v2 outside of mutex protection!

End of game. Needs atomics to comply with the standard.

Re: Advanced (for me) Question About Keyword volatile

<svmu8i$e3q$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20684&group=comp.lang.c#20684

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Tue, 1 Mar 2022 21:10:42 -0800
Organization: A noiseless patient Spider
Lines: 122
Message-ID: <svmu8i$e3q$2@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me> <svmsfh$49c$1@dont-email.me>
<svmt1v$594$4@dont-email.me> <svmtp2$b27$2@dont-email.me>
<svmtvj$bja$3@dont-email.me> <svmu68$d2h$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Mar 2022 05:10:43 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d4a417dfd5e5fa43753e81c21b04ad49";
logging-data="14458"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1//apgPKxD+Vtg6li9T1m6TWP4LEdGgKqY="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:IChVxTHZpVMLp5QRO581dtuV2vo=
In-Reply-To: <svmu68$d2h$2@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 2 Mar 2022 05:10 UTC

On 3/1/2022 9:09 PM, Bonita Montero wrote:
> Am 02.03.2022 um 06:05 schrieb Chris M. Thomasson:
>> On 3/1/2022 9:02 PM, Bonita Montero wrote:
>>> Am 02.03.2022 um 05:50 schrieb Chris M. Thomasson:
>>>> On 3/1/2022 8:40 PM, Bonita Montero wrote:
>>>>> Am 02.03.2022 um 05:29 schrieb Chris M. Thomasson:
>>>>>> On 3/1/2022 8:12 PM, Bonita Montero wrote:
>>>>>>> Am 02.03.2022 um 04:54 schrieb Chris M. Thomasson:
>>>>>>>> On 3/1/2022 7:45 PM, Bonita Montero wrote:
>>>>>>>>> Am 01.03.2022 um 22:32 schrieb Chris M. Thomasson:
>>>>>>>>>> On 2/28/2022 11:51 PM, Bonita Montero wrote:
>>>>>>>>>>> Am 28.02.2022 um 01:14 schrieb Chris M. Thomasson:
>>>>>>>>>>>> On 2/27/2022 2:35 PM, das...@gmail.com wrote:
>>>>>>>>>>>>> I have 3 variables used as interface variables between 2
>>>>>>>>>>>>> threads. Thread A writes the variables, and Thread B reads
>>>>>>>>>>>>> them.  Let me call them v1, v2, and v3.
>>>>>>>>>>>>>
>>>>>>>>>>>>> I buffer (or snapshot) them into local variables.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Question:  Do the local variables need to be declared
>>>>>>>>>>>>> volatile as well?
>>>>>>>>>>>>
>>>>>>>>>>>> The local variables are fine, and do not need to be
>>>>>>>>>>>> atomic/volatile, ect... Btw, think about using C atomic's
>>>>>>>>>>>> instead of volatile. You might be interested in a seqlock:
>>>>>>>>>>>> https://en.wikipedia.org/wiki/Seqlock
>>>>>>>>>>>> (read all)
>>>>>>>>>>>> They are geared to a read-mostly, write rarely pattern.
>>>>>>>>>>>
>>>>>>>>>>> Seqlocks don't make sense in user-space as they're lock-free and
>>>>>>>>>>> a writer, having made the seq-counter odd, may be easily
>>>>>>>>>>> scheduled
>>>>>>>>>>> away before making the seq-counter even again.
>>>>>>>>>>
>>>>>>>>>> Huh? The writers use a mutex. So, how lock-free is a writer?
>>>>>>>>>> For some reason, I don't think you have ever used one.
>>>>>>>>>
>>>>>>>>> Seqlocks need disabling the scheduler on a core while writing
>>>>>>>>> that a writer can't be scheduled away. That's not possible in
>>>>>>>>> user-mode.
>>>>>>>>
>>>>>>>> Huh? Wow. This basically confirms that you have never used a
>>>>>>>> seqlock in user land. Remember that the writer uses a normal
>>>>>>>> mutex. Now, a friend of mine created a really neat mutation of a
>>>>>>>> seqlock:
>>>>>>>
>>>>>>> No, readers and writers spin.
>>>>>>> Otherwise you don't have a seq-lock but sth. different.
>>>>>>> Look how it is implemented in the Linux kernel.
>>>>>>
>>>>>>
>>>>>> The basic seqlock minus the tricky membars:
>>>>>>
>>>>>> // quick and crude pseudo-code
>>>>>>
>>>>>> struct state { int a = 0; }
>>>>>> mutex g_lock;
>>>>>> atomic_unsigned g_ver = 0;
>>>>>>
>>>>>> state g_state;
>>>>>>
>>>>>> // writers
>>>>>> lock(g_lock);
>>>>>>    ++ver;
>>>>>>
>>>>>>      ++g_state.a;
>>>>>>
>>>>>>    ++ver;
>>>>>> unlock(g_lock);
>>>>>>
>>>>>>
>>>>>> // readers
>>>>>> state lstate;
>>>>>>
>>>>>> for (;;)
>>>>>> {
>>>>>>    unsigned ver0 = g_ver;
>>>>>>
>>>>>>      lstate = g_state;
>>>>>>
>>>>>>    unsigned ver1 = g_ver;
>>>>>>
>>>>>>
>>>>>>    if ((! (ver0 & 1)) && (ver0 == ver1))
>>>>>>    {
>>>>>>       break;
>>>>>>    }
>>>>>>
>>>>>>
>>>>>>    // A reader spun! Humm...
>>>>>>    // yield, backoff, do something else
>>>>>> }
>>>>>>
>>>>>>
>>>>>> The pattern is read-mostly, write-rarely. Fast reads, slow writes.
>>>>>> It works in user-land.
>>>>>
>>>>> Boy, you're so ultimately studpid.
>>>>>
>>>>> Readers could spin for a long time when whe writer is scheduled
>>>>> away. So the approach of 1024 cores is not tolerable in userspace
>>>>> and seqlocks only make sense in kernel space where the writer could
>>>>> disable scheduling while spinning of modifying.
>>>>
>>>> A writer never spins! God damn it. LOL!
>>>
>>> With this stupid 1024 cores implementation not.
>>
>> Huh? A traditional seqlock uses a lock for a writer. You really need
>> to calm down and read about seqlocks.
>
> That's linux seqlock-structure:
>
> typedef struct {
>     struct seqcount seqcount;
>     spinlock_t lock;
> } seqlock_t;
>
> Where's the mutex ?

Humm... I am going to guess that the spinlock_t is the mutual exclusion
lock here. LOL! Are you kidding me?

Re: Advanced (for me) Question About Keyword volatile

<svmua2$d2h$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20685&group=comp.lang.c#20685

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Wed, 2 Mar 2022 06:11:34 +0100
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <svmua2$d2h$3@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svkl61$vca$1@dont-email.me> <svmto3$bja$1@dont-email.me>
<svmtv7$cg3$1@dont-email.me> <svmu6m$e3q$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 05:11:30 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="13393"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19EUfrfIVeCYTl2TQKAV00WQpAwh60NUac="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:mAV2PYjvQVr1t21Rp5u2zDmNthQ=
In-Reply-To: <svmu6m$e3q$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 05:11 UTC

Am 02.03.2022 um 06:09 schrieb Chris M. Thomasson:
> On 3/1/2022 9:05 PM, Bonita Montero wrote:
>>> BAM! local_v2 just read v2 outside of the mutex protection. ...
>>
>> That's not what he actually does.
>>
>
> Oh yes he does! Calm down and read it again.

No, his volatile-accesses are _all_ guarded my mutexes and I said
that when the mutexes include proper barriers volatile isn't needed.

Re: Advanced (for me) Question About Keyword volatile

<svmubk$d2h$4@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20686&group=comp.lang.c#20686

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Wed, 2 Mar 2022 06:12:24 +0100
Organization: A noiseless patient Spider
Lines: 127
Message-ID: <svmubk$d2h$4@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me> <svmsfh$49c$1@dont-email.me>
<svmt1v$594$4@dont-email.me> <svmtp2$b27$2@dont-email.me>
<svmtvj$bja$3@dont-email.me> <svmu68$d2h$2@dont-email.me>
<svmu8i$e3q$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Mar 2022 05:12:20 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="13393"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nSPpFfwNb9f6xco999TABDL6gqoYr/hw="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:hN1AEZ1quxcJupqqvf+tq2Nivms=
In-Reply-To: <svmu8i$e3q$2@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 05:12 UTC

Am 02.03.2022 um 06:10 schrieb Chris M. Thomasson:
> On 3/1/2022 9:09 PM, Bonita Montero wrote:
>> Am 02.03.2022 um 06:05 schrieb Chris M. Thomasson:
>>> On 3/1/2022 9:02 PM, Bonita Montero wrote:
>>>> Am 02.03.2022 um 05:50 schrieb Chris M. Thomasson:
>>>>> On 3/1/2022 8:40 PM, Bonita Montero wrote:
>>>>>> Am 02.03.2022 um 05:29 schrieb Chris M. Thomasson:
>>>>>>> On 3/1/2022 8:12 PM, Bonita Montero wrote:
>>>>>>>> Am 02.03.2022 um 04:54 schrieb Chris M. Thomasson:
>>>>>>>>> On 3/1/2022 7:45 PM, Bonita Montero wrote:
>>>>>>>>>> Am 01.03.2022 um 22:32 schrieb Chris M. Thomasson:
>>>>>>>>>>> On 2/28/2022 11:51 PM, Bonita Montero wrote:
>>>>>>>>>>>> Am 28.02.2022 um 01:14 schrieb Chris M. Thomasson:
>>>>>>>>>>>>> On 2/27/2022 2:35 PM, das...@gmail.com wrote:
>>>>>>>>>>>>>> I have 3 variables used as interface variables between 2
>>>>>>>>>>>>>> threads. Thread A writes the variables, and Thread B reads
>>>>>>>>>>>>>> them.  Let me call them v1, v2, and v3.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I buffer (or snapshot) them into local variables.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Question:  Do the local variables need to be declared
>>>>>>>>>>>>>> volatile as well?
>>>>>>>>>>>>>
>>>>>>>>>>>>> The local variables are fine, and do not need to be
>>>>>>>>>>>>> atomic/volatile, ect... Btw, think about using C atomic's
>>>>>>>>>>>>> instead of volatile. You might be interested in a seqlock:
>>>>>>>>>>>>> https://en.wikipedia.org/wiki/Seqlock
>>>>>>>>>>>>> (read all)
>>>>>>>>>>>>> They are geared to a read-mostly, write rarely pattern.
>>>>>>>>>>>>
>>>>>>>>>>>> Seqlocks don't make sense in user-space as they're lock-free
>>>>>>>>>>>> and
>>>>>>>>>>>> a writer, having made the seq-counter odd, may be easily
>>>>>>>>>>>> scheduled
>>>>>>>>>>>> away before making the seq-counter even again.
>>>>>>>>>>>
>>>>>>>>>>> Huh? The writers use a mutex. So, how lock-free is a writer?
>>>>>>>>>>> For some reason, I don't think you have ever used one.
>>>>>>>>>>
>>>>>>>>>> Seqlocks need disabling the scheduler on a core while writing
>>>>>>>>>> that a writer can't be scheduled away. That's not possible in
>>>>>>>>>> user-mode.
>>>>>>>>>
>>>>>>>>> Huh? Wow. This basically confirms that you have never used a
>>>>>>>>> seqlock in user land. Remember that the writer uses a normal
>>>>>>>>> mutex. Now, a friend of mine created a really neat mutation of
>>>>>>>>> a seqlock:
>>>>>>>>
>>>>>>>> No, readers and writers spin.
>>>>>>>> Otherwise you don't have a seq-lock but sth. different.
>>>>>>>> Look how it is implemented in the Linux kernel.
>>>>>>>
>>>>>>>
>>>>>>> The basic seqlock minus the tricky membars:
>>>>>>>
>>>>>>> // quick and crude pseudo-code
>>>>>>>
>>>>>>> struct state { int a = 0; }
>>>>>>> mutex g_lock;
>>>>>>> atomic_unsigned g_ver = 0;
>>>>>>>
>>>>>>> state g_state;
>>>>>>>
>>>>>>> // writers
>>>>>>> lock(g_lock);
>>>>>>>    ++ver;
>>>>>>>
>>>>>>>      ++g_state.a;
>>>>>>>
>>>>>>>    ++ver;
>>>>>>> unlock(g_lock);
>>>>>>>
>>>>>>>
>>>>>>> // readers
>>>>>>> state lstate;
>>>>>>>
>>>>>>> for (;;)
>>>>>>> {
>>>>>>>    unsigned ver0 = g_ver;
>>>>>>>
>>>>>>>      lstate = g_state;
>>>>>>>
>>>>>>>    unsigned ver1 = g_ver;
>>>>>>>
>>>>>>>
>>>>>>>    if ((! (ver0 & 1)) && (ver0 == ver1))
>>>>>>>    {
>>>>>>>       break;
>>>>>>>    }
>>>>>>>
>>>>>>>
>>>>>>>    // A reader spun! Humm...
>>>>>>>    // yield, backoff, do something else
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> The pattern is read-mostly, write-rarely. Fast reads, slow
>>>>>>> writes. It works in user-land.
>>>>>>
>>>>>> Boy, you're so ultimately studpid.
>>>>>>
>>>>>> Readers could spin for a long time when whe writer is scheduled
>>>>>> away. So the approach of 1024 cores is not tolerable in userspace
>>>>>> and seqlocks only make sense in kernel space where the writer could
>>>>>> disable scheduling while spinning of modifying.
>>>>>
>>>>> A writer never spins! God damn it. LOL!
>>>>
>>>> With this stupid 1024 cores implementation not.
>>>
>>> Huh? A traditional seqlock uses a lock for a writer. You really need
>>> to calm down and read about seqlocks.
>>
>> That's linux seqlock-structure:
>>
>> typedef struct {
>>      struct seqcount seqcount;
>>      spinlock_t lock;
>> } seqlock_t;
>>
>> Where's the mutex ?
>
> Humm... I am going to guess that the spinlock_t is the mutual exclusion
> lock here. LOL! Are you kidding me?

spinlock_t is a spinlock, and not a mutex.
Linux kernel seqlocks don't include a mutex.

Re: Advanced (for me) Question About Keyword volatile

<svmuoo$h8q$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20687&group=comp.lang.c#20687

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Tue, 1 Mar 2022 21:19:18 -0800
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <svmuoo$h8q$1@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svkl61$vca$1@dont-email.me> <svmto3$bja$1@dont-email.me>
<svmtv7$cg3$1@dont-email.me> <svmu6m$e3q$1@dont-email.me>
<svmua2$d2h$3@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 05:19:20 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d4a417dfd5e5fa43753e81c21b04ad49";
logging-data="17690"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UKma98DwW+UERf2AOFjQejwraBsK5ICo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:hW7b5Uf1010SMIsmnImBCf6Jwno=
In-Reply-To: <svmua2$d2h$3@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 2 Mar 2022 05:19 UTC

On 3/1/2022 9:11 PM, Bonita Montero wrote:
> Am 02.03.2022 um 06:09 schrieb Chris M. Thomasson:
>> On 3/1/2022 9:05 PM, Bonita Montero wrote:
>>>> BAM! local_v2 just read v2 outside of the mutex protection. ...
>>>
>>> That's not what he actually does.
>>>
>>
>> Oh yes he does! Calm down and read it again.
>
> No, his volatile-accesses are _all_ guarded my mutexes and I said
> that when the mutexes include proper barriers volatile isn't needed.

I know it works because of that for sure, however, for some damn reason
I still think this needs atomics with relaxed membars to be 100%
standard compliant wrt C.

Re: Advanced (for me) Question About Keyword volatile

<svmusq$h8q$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20688&group=comp.lang.c#20688

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Tue, 1 Mar 2022 21:21:29 -0800
Organization: A noiseless patient Spider
Lines: 132
Message-ID: <svmusq$h8q$2@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me> <svmsfh$49c$1@dont-email.me>
<svmt1v$594$4@dont-email.me> <svmtp2$b27$2@dont-email.me>
<svmtvj$bja$3@dont-email.me> <svmu68$d2h$2@dont-email.me>
<svmu8i$e3q$2@dont-email.me> <svmubk$d2h$4@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Mar 2022 05:21:30 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d4a417dfd5e5fa43753e81c21b04ad49";
logging-data="17690"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18H0WDdO02gfI90MUUIgvdlsFUEr9/67Nk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:mW4cC5PEkI6gH94AzP3/Kq5EEa4=
In-Reply-To: <svmubk$d2h$4@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 2 Mar 2022 05:21 UTC

On 3/1/2022 9:12 PM, Bonita Montero wrote:
> Am 02.03.2022 um 06:10 schrieb Chris M. Thomasson:
>> On 3/1/2022 9:09 PM, Bonita Montero wrote:
>>> Am 02.03.2022 um 06:05 schrieb Chris M. Thomasson:
>>>> On 3/1/2022 9:02 PM, Bonita Montero wrote:
>>>>> Am 02.03.2022 um 05:50 schrieb Chris M. Thomasson:
>>>>>> On 3/1/2022 8:40 PM, Bonita Montero wrote:
>>>>>>> Am 02.03.2022 um 05:29 schrieb Chris M. Thomasson:
>>>>>>>> On 3/1/2022 8:12 PM, Bonita Montero wrote:
>>>>>>>>> Am 02.03.2022 um 04:54 schrieb Chris M. Thomasson:
>>>>>>>>>> On 3/1/2022 7:45 PM, Bonita Montero wrote:
>>>>>>>>>>> Am 01.03.2022 um 22:32 schrieb Chris M. Thomasson:
>>>>>>>>>>>> On 2/28/2022 11:51 PM, Bonita Montero wrote:
>>>>>>>>>>>>> Am 28.02.2022 um 01:14 schrieb Chris M. Thomasson:
>>>>>>>>>>>>>> On 2/27/2022 2:35 PM, das...@gmail.com wrote:
>>>>>>>>>>>>>>> I have 3 variables used as interface variables between 2
>>>>>>>>>>>>>>> threads. Thread A writes the variables, and Thread B
>>>>>>>>>>>>>>> reads them.  Let me call them v1, v2, and v3.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I buffer (or snapshot) them into local variables.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Question:  Do the local variables need to be declared
>>>>>>>>>>>>>>> volatile as well?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> The local variables are fine, and do not need to be
>>>>>>>>>>>>>> atomic/volatile, ect... Btw, think about using C atomic's
>>>>>>>>>>>>>> instead of volatile. You might be interested in a seqlock:
>>>>>>>>>>>>>> https://en.wikipedia.org/wiki/Seqlock
>>>>>>>>>>>>>> (read all)
>>>>>>>>>>>>>> They are geared to a read-mostly, write rarely pattern.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Seqlocks don't make sense in user-space as they're
>>>>>>>>>>>>> lock-free and
>>>>>>>>>>>>> a writer, having made the seq-counter odd, may be easily
>>>>>>>>>>>>> scheduled
>>>>>>>>>>>>> away before making the seq-counter even again.
>>>>>>>>>>>>
>>>>>>>>>>>> Huh? The writers use a mutex. So, how lock-free is a writer?
>>>>>>>>>>>> For some reason, I don't think you have ever used one.
>>>>>>>>>>>
>>>>>>>>>>> Seqlocks need disabling the scheduler on a core while writing
>>>>>>>>>>> that a writer can't be scheduled away. That's not possible in
>>>>>>>>>>> user-mode.
>>>>>>>>>>
>>>>>>>>>> Huh? Wow. This basically confirms that you have never used a
>>>>>>>>>> seqlock in user land. Remember that the writer uses a normal
>>>>>>>>>> mutex. Now, a friend of mine created a really neat mutation of
>>>>>>>>>> a seqlock:
>>>>>>>>>
>>>>>>>>> No, readers and writers spin.
>>>>>>>>> Otherwise you don't have a seq-lock but sth. different.
>>>>>>>>> Look how it is implemented in the Linux kernel.
>>>>>>>>
>>>>>>>>
>>>>>>>> The basic seqlock minus the tricky membars:
>>>>>>>>
>>>>>>>> // quick and crude pseudo-code
>>>>>>>>
>>>>>>>> struct state { int a = 0; }
>>>>>>>> mutex g_lock;
>>>>>>>> atomic_unsigned g_ver = 0;
>>>>>>>>
>>>>>>>> state g_state;
>>>>>>>>
>>>>>>>> // writers
>>>>>>>> lock(g_lock);
>>>>>>>>    ++ver;
>>>>>>>>
>>>>>>>>      ++g_state.a;
>>>>>>>>
>>>>>>>>    ++ver;
>>>>>>>> unlock(g_lock);
>>>>>>>>
>>>>>>>>
>>>>>>>> // readers
>>>>>>>> state lstate;
>>>>>>>>
>>>>>>>> for (;;)
>>>>>>>> {
>>>>>>>>    unsigned ver0 = g_ver;
>>>>>>>>
>>>>>>>>      lstate = g_state;
>>>>>>>>
>>>>>>>>    unsigned ver1 = g_ver;
>>>>>>>>
>>>>>>>>
>>>>>>>>    if ((! (ver0 & 1)) && (ver0 == ver1))
>>>>>>>>    {
>>>>>>>>       break;
>>>>>>>>    }
>>>>>>>>
>>>>>>>>
>>>>>>>>    // A reader spun! Humm...
>>>>>>>>    // yield, backoff, do something else
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>> The pattern is read-mostly, write-rarely. Fast reads, slow
>>>>>>>> writes. It works in user-land.
>>>>>>>
>>>>>>> Boy, you're so ultimately studpid.
>>>>>>>
>>>>>>> Readers could spin for a long time when whe writer is scheduled
>>>>>>> away. So the approach of 1024 cores is not tolerable in userspace
>>>>>>> and seqlocks only make sense in kernel space where the writer could
>>>>>>> disable scheduling while spinning of modifying.
>>>>>>
>>>>>> A writer never spins! God damn it. LOL!
>>>>>
>>>>> With this stupid 1024 cores implementation not.
>>>>
>>>> Huh? A traditional seqlock uses a lock for a writer. You really need
>>>> to calm down and read about seqlocks.
>>>
>>> That's linux seqlock-structure:
>>>
>>> typedef struct {
>>>      struct seqcount seqcount;
>>>      spinlock_t lock;
>>> } seqlock_t;
>>>
>>> Where's the mutex ?
>>
>> Humm... I am going to guess that the spinlock_t is the mutual
>> exclusion lock here. LOL! Are you kidding me?
>
> spinlock_t is a spinlock, and not a mutex.
> Linux kernel seqlocks don't include a mutex.

Using a mutex in user land is fine! Using a seqlock with a mutex in
userland is fine as long as your usage pattern fits in with read-mostly,
write rarely.

Re: Advanced (for me) Question About Keyword volatile

<svmv25$ioe$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20689&group=comp.lang.c#20689

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Wed, 2 Mar 2022 06:24:25 +0100
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <svmv25$ioe$1@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svkl61$vca$1@dont-email.me> <svmto3$bja$1@dont-email.me>
<svmtv7$cg3$1@dont-email.me> <svmu6m$e3q$1@dont-email.me>
<svmua2$d2h$3@dont-email.me> <svmuoo$h8q$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 05:24:21 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="19214"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18P2iOJ8STC56vVSjFDrxFsNU4upS4F6OY="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:Ns0Vb/LibTrKjHl8X7Hu3FvsdBc=
In-Reply-To: <svmuoo$h8q$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 05:24 UTC

Am 02.03.2022 um 06:19 schrieb Chris M. Thomasson:
> On 3/1/2022 9:11 PM, Bonita Montero wrote:
>> Am 02.03.2022 um 06:09 schrieb Chris M. Thomasson:
>>> On 3/1/2022 9:05 PM, Bonita Montero wrote:
>>>>> BAM! local_v2 just read v2 outside of the mutex protection. ...
>>>>
>>>> That's not what he actually does.
>>>>
>>>
>>> Oh yes he does! Calm down and read it again.
>>
>> No, his volatile-accesses are _all_ guarded my mutexes and I said
>> that when the mutexes include proper barriers volatile isn't needed.
>
> I know it works because of that for sure, ...

We're talking about his code and that volatiles aren't necessary
and not what you're dreaming about.

Re: Advanced (for me) Question About Keyword volatile

<svmv4f$ioe$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20690&group=comp.lang.c#20690

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Wed, 2 Mar 2022 06:25:40 +0100
Organization: A noiseless patient Spider
Lines: 138
Message-ID: <svmv4f$ioe$2@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me> <svmsfh$49c$1@dont-email.me>
<svmt1v$594$4@dont-email.me> <svmtp2$b27$2@dont-email.me>
<svmtvj$bja$3@dont-email.me> <svmu68$d2h$2@dont-email.me>
<svmu8i$e3q$2@dont-email.me> <svmubk$d2h$4@dont-email.me>
<svmusq$h8q$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Mar 2022 05:25:35 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="19214"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zlpxAPkvIamfYfFbO5vrI5ruBYd7KPu0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:i4n/zSIWG0HXQrZeR9/rXBpKxzg=
In-Reply-To: <svmusq$h8q$2@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 05:25 UTC

Am 02.03.2022 um 06:21 schrieb Chris M. Thomasson:
> On 3/1/2022 9:12 PM, Bonita Montero wrote:
>> Am 02.03.2022 um 06:10 schrieb Chris M. Thomasson:
>>> On 3/1/2022 9:09 PM, Bonita Montero wrote:
>>>> Am 02.03.2022 um 06:05 schrieb Chris M. Thomasson:
>>>>> On 3/1/2022 9:02 PM, Bonita Montero wrote:
>>>>>> Am 02.03.2022 um 05:50 schrieb Chris M. Thomasson:
>>>>>>> On 3/1/2022 8:40 PM, Bonita Montero wrote:
>>>>>>>> Am 02.03.2022 um 05:29 schrieb Chris M. Thomasson:
>>>>>>>>> On 3/1/2022 8:12 PM, Bonita Montero wrote:
>>>>>>>>>> Am 02.03.2022 um 04:54 schrieb Chris M. Thomasson:
>>>>>>>>>>> On 3/1/2022 7:45 PM, Bonita Montero wrote:
>>>>>>>>>>>> Am 01.03.2022 um 22:32 schrieb Chris M. Thomasson:
>>>>>>>>>>>>> On 2/28/2022 11:51 PM, Bonita Montero wrote:
>>>>>>>>>>>>>> Am 28.02.2022 um 01:14 schrieb Chris M. Thomasson:
>>>>>>>>>>>>>>> On 2/27/2022 2:35 PM, das...@gmail.com wrote:
>>>>>>>>>>>>>>>> I have 3 variables used as interface variables between 2
>>>>>>>>>>>>>>>> threads. Thread A writes the variables, and Thread B
>>>>>>>>>>>>>>>> reads them.  Let me call them v1, v2, and v3.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I buffer (or snapshot) them into local variables.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Question:  Do the local variables need to be declared
>>>>>>>>>>>>>>>> volatile as well?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> The local variables are fine, and do not need to be
>>>>>>>>>>>>>>> atomic/volatile, ect... Btw, think about using C atomic's
>>>>>>>>>>>>>>> instead of volatile. You might be interested in a seqlock:
>>>>>>>>>>>>>>> https://en.wikipedia.org/wiki/Seqlock
>>>>>>>>>>>>>>> (read all)
>>>>>>>>>>>>>>> They are geared to a read-mostly, write rarely pattern.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Seqlocks don't make sense in user-space as they're
>>>>>>>>>>>>>> lock-free and
>>>>>>>>>>>>>> a writer, having made the seq-counter odd, may be easily
>>>>>>>>>>>>>> scheduled
>>>>>>>>>>>>>> away before making the seq-counter even again.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Huh? The writers use a mutex. So, how lock-free is a writer?
>>>>>>>>>>>>> For some reason, I don't think you have ever used one.
>>>>>>>>>>>>
>>>>>>>>>>>> Seqlocks need disabling the scheduler on a core while writing
>>>>>>>>>>>> that a writer can't be scheduled away. That's not possible in
>>>>>>>>>>>> user-mode.
>>>>>>>>>>>
>>>>>>>>>>> Huh? Wow. This basically confirms that you have never used a
>>>>>>>>>>> seqlock in user land. Remember that the writer uses a normal
>>>>>>>>>>> mutex. Now, a friend of mine created a really neat mutation
>>>>>>>>>>> of a seqlock:
>>>>>>>>>>
>>>>>>>>>> No, readers and writers spin.
>>>>>>>>>> Otherwise you don't have a seq-lock but sth. different.
>>>>>>>>>> Look how it is implemented in the Linux kernel.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> The basic seqlock minus the tricky membars:
>>>>>>>>>
>>>>>>>>> // quick and crude pseudo-code
>>>>>>>>>
>>>>>>>>> struct state { int a = 0; }
>>>>>>>>> mutex g_lock;
>>>>>>>>> atomic_unsigned g_ver = 0;
>>>>>>>>>
>>>>>>>>> state g_state;
>>>>>>>>>
>>>>>>>>> // writers
>>>>>>>>> lock(g_lock);
>>>>>>>>>    ++ver;
>>>>>>>>>
>>>>>>>>>      ++g_state.a;
>>>>>>>>>
>>>>>>>>>    ++ver;
>>>>>>>>> unlock(g_lock);
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> // readers
>>>>>>>>> state lstate;
>>>>>>>>>
>>>>>>>>> for (;;)
>>>>>>>>> {
>>>>>>>>>    unsigned ver0 = g_ver;
>>>>>>>>>
>>>>>>>>>      lstate = g_state;
>>>>>>>>>
>>>>>>>>>    unsigned ver1 = g_ver;
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>    if ((! (ver0 & 1)) && (ver0 == ver1))
>>>>>>>>>    {
>>>>>>>>>       break;
>>>>>>>>>    }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>    // A reader spun! Humm...
>>>>>>>>>    // yield, backoff, do something else
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> The pattern is read-mostly, write-rarely. Fast reads, slow
>>>>>>>>> writes. It works in user-land.
>>>>>>>>
>>>>>>>> Boy, you're so ultimately studpid.
>>>>>>>>
>>>>>>>> Readers could spin for a long time when whe writer is scheduled
>>>>>>>> away. So the approach of 1024 cores is not tolerable in userspace
>>>>>>>> and seqlocks only make sense in kernel space where the writer could
>>>>>>>> disable scheduling while spinning of modifying.
>>>>>>>
>>>>>>> A writer never spins! God damn it. LOL!
>>>>>>
>>>>>> With this stupid 1024 cores implementation not.
>>>>>
>>>>> Huh? A traditional seqlock uses a lock for a writer. You really
>>>>> need to calm down and read about seqlocks.
>>>>
>>>> That's linux seqlock-structure:
>>>>
>>>> typedef struct {
>>>>      struct seqcount seqcount;
>>>>      spinlock_t lock;
>>>> } seqlock_t;
>>>>
>>>> Where's the mutex ?
>>>
>>> Humm... I am going to guess that the spinlock_t is the mutual
>>> exclusion lock here. LOL! Are you kidding me?
>>
>> spinlock_t is a spinlock, and not a mutex.
>> Linux kernel seqlocks don't include a mutex.
>
> Using a mutex in user land is fine! Using a seqlock with a mutex in
> userland is fine as long as your usage pattern fits in with read-mostly,
> write rarely.

Using mutexes for "seqlocks" on the writer-side doesn't preserve the
readers from spinning. So seqlocks in user-space implmented in that
way are a strupid idea.

Re: Advanced (for me) Question About Keyword volatile

<svmvg3$lb3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20691&group=comp.lang.c#20691

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Tue, 1 Mar 2022 21:31:47 -0800
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <svmvg3$lb3$1@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svkl61$vca$1@dont-email.me> <svmto3$bja$1@dont-email.me>
<svmtv7$cg3$1@dont-email.me> <svmu6m$e3q$1@dont-email.me>
<svmua2$d2h$3@dont-email.me> <svmuoo$h8q$1@dont-email.me>
<svmv25$ioe$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 05:31:48 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d4a417dfd5e5fa43753e81c21b04ad49";
logging-data="21859"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zfrFjL+fEudJ+ZG79ZWZ4VtwuAnVPZiI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:bk7XxiemS9OKycXVfwVrMZpcL70=
In-Reply-To: <svmv25$ioe$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 2 Mar 2022 05:31 UTC

On 3/1/2022 9:24 PM, Bonita Montero wrote:
> Am 02.03.2022 um 06:19 schrieb Chris M. Thomasson:
>> On 3/1/2022 9:11 PM, Bonita Montero wrote:
>>> Am 02.03.2022 um 06:09 schrieb Chris M. Thomasson:
>>>> On 3/1/2022 9:05 PM, Bonita Montero wrote:
>>>>>> BAM! local_v2 just read v2 outside of the mutex protection. ...
>>>>>
>>>>> That's not what he actually does.
>>>>>
>>>>
>>>> Oh yes he does! Calm down and read it again.
>>>
>>> No, his volatile-accesses are _all_ guarded my mutexes and I said
>>> that when the mutexes include proper barriers volatile isn't needed.
>>
>> I know it works because of that for sure, ...
>
> We're talking about his code and that volatiles aren't necessary
> and not what you're dreaming about.
>

Yeah. You are right, but iirc there was some odd wording in the C11
standard that it might violate. I need to refresh myself.

Re: Advanced (for me) Question About Keyword volatile

<svmvin$lb3$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20692&group=comp.lang.c#20692

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Tue, 1 Mar 2022 21:33:10 -0800
Organization: A noiseless patient Spider
Lines: 144
Message-ID: <svmvin$lb3$2@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me> <svmsfh$49c$1@dont-email.me>
<svmt1v$594$4@dont-email.me> <svmtp2$b27$2@dont-email.me>
<svmtvj$bja$3@dont-email.me> <svmu68$d2h$2@dont-email.me>
<svmu8i$e3q$2@dont-email.me> <svmubk$d2h$4@dont-email.me>
<svmusq$h8q$2@dont-email.me> <svmv4f$ioe$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Mar 2022 05:33:11 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d4a417dfd5e5fa43753e81c21b04ad49";
logging-data="21859"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Vtk5QVKAA6u1FpgDfakY/NtecNPhaMls="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:S0fWL8d6hcQRuE3EKcRYvGKbHTo=
In-Reply-To: <svmv4f$ioe$2@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 2 Mar 2022 05:33 UTC

On 3/1/2022 9:25 PM, Bonita Montero wrote:
> Am 02.03.2022 um 06:21 schrieb Chris M. Thomasson:
>> On 3/1/2022 9:12 PM, Bonita Montero wrote:
>>> Am 02.03.2022 um 06:10 schrieb Chris M. Thomasson:
>>>> On 3/1/2022 9:09 PM, Bonita Montero wrote:
>>>>> Am 02.03.2022 um 06:05 schrieb Chris M. Thomasson:
>>>>>> On 3/1/2022 9:02 PM, Bonita Montero wrote:
>>>>>>> Am 02.03.2022 um 05:50 schrieb Chris M. Thomasson:
>>>>>>>> On 3/1/2022 8:40 PM, Bonita Montero wrote:
>>>>>>>>> Am 02.03.2022 um 05:29 schrieb Chris M. Thomasson:
>>>>>>>>>> On 3/1/2022 8:12 PM, Bonita Montero wrote:
>>>>>>>>>>> Am 02.03.2022 um 04:54 schrieb Chris M. Thomasson:
>>>>>>>>>>>> On 3/1/2022 7:45 PM, Bonita Montero wrote:
>>>>>>>>>>>>> Am 01.03.2022 um 22:32 schrieb Chris M. Thomasson:
>>>>>>>>>>>>>> On 2/28/2022 11:51 PM, Bonita Montero wrote:
>>>>>>>>>>>>>>> Am 28.02.2022 um 01:14 schrieb Chris M. Thomasson:
>>>>>>>>>>>>>>>> On 2/27/2022 2:35 PM, das...@gmail.com wrote:
>>>>>>>>>>>>>>>>> I have 3 variables used as interface variables between
>>>>>>>>>>>>>>>>> 2 threads. Thread A writes the variables, and Thread B
>>>>>>>>>>>>>>>>> reads them.  Let me call them v1, v2, and v3.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> I buffer (or snapshot) them into local variables.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Question:  Do the local variables need to be declared
>>>>>>>>>>>>>>>>> volatile as well?
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> The local variables are fine, and do not need to be
>>>>>>>>>>>>>>>> atomic/volatile, ect... Btw, think about using C
>>>>>>>>>>>>>>>> atomic's instead of volatile. You might be interested in
>>>>>>>>>>>>>>>> a seqlock:
>>>>>>>>>>>>>>>> https://en.wikipedia.org/wiki/Seqlock
>>>>>>>>>>>>>>>> (read all)
>>>>>>>>>>>>>>>> They are geared to a read-mostly, write rarely pattern.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Seqlocks don't make sense in user-space as they're
>>>>>>>>>>>>>>> lock-free and
>>>>>>>>>>>>>>> a writer, having made the seq-counter odd, may be easily
>>>>>>>>>>>>>>> scheduled
>>>>>>>>>>>>>>> away before making the seq-counter even again.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Huh? The writers use a mutex. So, how lock-free is a writer?
>>>>>>>>>>>>>> For some reason, I don't think you have ever used one.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Seqlocks need disabling the scheduler on a core while writing
>>>>>>>>>>>>> that a writer can't be scheduled away. That's not possible in
>>>>>>>>>>>>> user-mode.
>>>>>>>>>>>>
>>>>>>>>>>>> Huh? Wow. This basically confirms that you have never used a
>>>>>>>>>>>> seqlock in user land. Remember that the writer uses a normal
>>>>>>>>>>>> mutex. Now, a friend of mine created a really neat mutation
>>>>>>>>>>>> of a seqlock:
>>>>>>>>>>>
>>>>>>>>>>> No, readers and writers spin.
>>>>>>>>>>> Otherwise you don't have a seq-lock but sth. different.
>>>>>>>>>>> Look how it is implemented in the Linux kernel.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> The basic seqlock minus the tricky membars:
>>>>>>>>>>
>>>>>>>>>> // quick and crude pseudo-code
>>>>>>>>>>
>>>>>>>>>> struct state { int a = 0; }
>>>>>>>>>> mutex g_lock;
>>>>>>>>>> atomic_unsigned g_ver = 0;
>>>>>>>>>>
>>>>>>>>>> state g_state;
>>>>>>>>>>
>>>>>>>>>> // writers
>>>>>>>>>> lock(g_lock);
>>>>>>>>>>    ++ver;
>>>>>>>>>>
>>>>>>>>>>      ++g_state.a;
>>>>>>>>>>
>>>>>>>>>>    ++ver;
>>>>>>>>>> unlock(g_lock);
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> // readers
>>>>>>>>>> state lstate;
>>>>>>>>>>
>>>>>>>>>> for (;;)
>>>>>>>>>> {
>>>>>>>>>>    unsigned ver0 = g_ver;
>>>>>>>>>>
>>>>>>>>>>      lstate = g_state;
>>>>>>>>>>
>>>>>>>>>>    unsigned ver1 = g_ver;
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>    if ((! (ver0 & 1)) && (ver0 == ver1))
>>>>>>>>>>    {
>>>>>>>>>>       break;
>>>>>>>>>>    }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>    // A reader spun! Humm...
>>>>>>>>>>    // yield, backoff, do something else
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> The pattern is read-mostly, write-rarely. Fast reads, slow
>>>>>>>>>> writes. It works in user-land.
>>>>>>>>>
>>>>>>>>> Boy, you're so ultimately studpid.
>>>>>>>>>
>>>>>>>>> Readers could spin for a long time when whe writer is scheduled
>>>>>>>>> away. So the approach of 1024 cores is not tolerable in userspace
>>>>>>>>> and seqlocks only make sense in kernel space where the writer
>>>>>>>>> could
>>>>>>>>> disable scheduling while spinning of modifying.
>>>>>>>>
>>>>>>>> A writer never spins! God damn it. LOL!
>>>>>>>
>>>>>>> With this stupid 1024 cores implementation not.
>>>>>>
>>>>>> Huh? A traditional seqlock uses a lock for a writer. You really
>>>>>> need to calm down and read about seqlocks.
>>>>>
>>>>> That's linux seqlock-structure:
>>>>>
>>>>> typedef struct {
>>>>>      struct seqcount seqcount;
>>>>>      spinlock_t lock;
>>>>> } seqlock_t;
>>>>>
>>>>> Where's the mutex ?
>>>>
>>>> Humm... I am going to guess that the spinlock_t is the mutual
>>>> exclusion lock here. LOL! Are you kidding me?
>>>
>>> spinlock_t is a spinlock, and not a mutex.
>>> Linux kernel seqlocks don't include a mutex.
>>
>> Using a mutex in user land is fine! Using a seqlock with a mutex in
>> userland is fine as long as your usage pattern fits in with
>> read-mostly, write rarely.
>
> Using mutexes for "seqlocks" on the writer-side doesn't preserve the
> readers from spinning. So seqlocks in user-space implmented in that
> way are a strupid idea.
>


Click here to read the complete article
Re: Advanced (for me) Question About Keyword volatile

<svmvv2$o5p$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20693&group=comp.lang.c#20693

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Wed, 2 Mar 2022 06:39:50 +0100
Organization: A noiseless patient Spider
Lines: 154
Message-ID: <svmvv2$o5p$1@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me> <svmsfh$49c$1@dont-email.me>
<svmt1v$594$4@dont-email.me> <svmtp2$b27$2@dont-email.me>
<svmtvj$bja$3@dont-email.me> <svmu68$d2h$2@dont-email.me>
<svmu8i$e3q$2@dont-email.me> <svmubk$d2h$4@dont-email.me>
<svmusq$h8q$2@dont-email.me> <svmv4f$ioe$2@dont-email.me>
<svmvin$lb3$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Mar 2022 05:39:46 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="24761"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2oU252mBgUafRNQb7mGi0bNcEfbHQPuo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:9E0zmB2q7I7iADCZu4QF6OmS380=
In-Reply-To: <svmvin$lb3$2@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 05:39 UTC

Am 02.03.2022 um 06:33 schrieb Chris M. Thomasson:
> On 3/1/2022 9:25 PM, Bonita Montero wrote:
>> Am 02.03.2022 um 06:21 schrieb Chris M. Thomasson:
>>> On 3/1/2022 9:12 PM, Bonita Montero wrote:
>>>> Am 02.03.2022 um 06:10 schrieb Chris M. Thomasson:
>>>>> On 3/1/2022 9:09 PM, Bonita Montero wrote:
>>>>>> Am 02.03.2022 um 06:05 schrieb Chris M. Thomasson:
>>>>>>> On 3/1/2022 9:02 PM, Bonita Montero wrote:
>>>>>>>> Am 02.03.2022 um 05:50 schrieb Chris M. Thomasson:
>>>>>>>>> On 3/1/2022 8:40 PM, Bonita Montero wrote:
>>>>>>>>>> Am 02.03.2022 um 05:29 schrieb Chris M. Thomasson:
>>>>>>>>>>> On 3/1/2022 8:12 PM, Bonita Montero wrote:
>>>>>>>>>>>> Am 02.03.2022 um 04:54 schrieb Chris M. Thomasson:
>>>>>>>>>>>>> On 3/1/2022 7:45 PM, Bonita Montero wrote:
>>>>>>>>>>>>>> Am 01.03.2022 um 22:32 schrieb Chris M. Thomasson:
>>>>>>>>>>>>>>> On 2/28/2022 11:51 PM, Bonita Montero wrote:
>>>>>>>>>>>>>>>> Am 28.02.2022 um 01:14 schrieb Chris M. Thomasson:
>>>>>>>>>>>>>>>>> On 2/27/2022 2:35 PM, das...@gmail.com wrote:
>>>>>>>>>>>>>>>>>> I have 3 variables used as interface variables between
>>>>>>>>>>>>>>>>>> 2 threads. Thread A writes the variables, and Thread B
>>>>>>>>>>>>>>>>>> reads them.  Let me call them v1, v2, and v3.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> I buffer (or snapshot) them into local variables.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Question:  Do the local variables need to be declared
>>>>>>>>>>>>>>>>>> volatile as well?
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> The local variables are fine, and do not need to be
>>>>>>>>>>>>>>>>> atomic/volatile, ect... Btw, think about using C
>>>>>>>>>>>>>>>>> atomic's instead of volatile. You might be interested
>>>>>>>>>>>>>>>>> in a seqlock:
>>>>>>>>>>>>>>>>> https://en.wikipedia.org/wiki/Seqlock
>>>>>>>>>>>>>>>>> (read all)
>>>>>>>>>>>>>>>>> They are geared to a read-mostly, write rarely pattern.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Seqlocks don't make sense in user-space as they're
>>>>>>>>>>>>>>>> lock-free and
>>>>>>>>>>>>>>>> a writer, having made the seq-counter odd, may be easily
>>>>>>>>>>>>>>>> scheduled
>>>>>>>>>>>>>>>> away before making the seq-counter even again.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Huh? The writers use a mutex. So, how lock-free is a writer?
>>>>>>>>>>>>>>> For some reason, I don't think you have ever used one.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Seqlocks need disabling the scheduler on a core while writing
>>>>>>>>>>>>>> that a writer can't be scheduled away. That's not possible in
>>>>>>>>>>>>>> user-mode.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Huh? Wow. This basically confirms that you have never used
>>>>>>>>>>>>> a seqlock in user land. Remember that the writer uses a
>>>>>>>>>>>>> normal mutex. Now, a friend of mine created a really neat
>>>>>>>>>>>>> mutation of a seqlock:
>>>>>>>>>>>>
>>>>>>>>>>>> No, readers and writers spin.
>>>>>>>>>>>> Otherwise you don't have a seq-lock but sth. different.
>>>>>>>>>>>> Look how it is implemented in the Linux kernel.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> The basic seqlock minus the tricky membars:
>>>>>>>>>>>
>>>>>>>>>>> // quick and crude pseudo-code
>>>>>>>>>>>
>>>>>>>>>>> struct state { int a = 0; }
>>>>>>>>>>> mutex g_lock;
>>>>>>>>>>> atomic_unsigned g_ver = 0;
>>>>>>>>>>>
>>>>>>>>>>> state g_state;
>>>>>>>>>>>
>>>>>>>>>>> // writers
>>>>>>>>>>> lock(g_lock);
>>>>>>>>>>>    ++ver;
>>>>>>>>>>>
>>>>>>>>>>>      ++g_state.a;
>>>>>>>>>>>
>>>>>>>>>>>    ++ver;
>>>>>>>>>>> unlock(g_lock);
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> // readers
>>>>>>>>>>> state lstate;
>>>>>>>>>>>
>>>>>>>>>>> for (;;)
>>>>>>>>>>> {
>>>>>>>>>>>    unsigned ver0 = g_ver;
>>>>>>>>>>>
>>>>>>>>>>>      lstate = g_state;
>>>>>>>>>>>
>>>>>>>>>>>    unsigned ver1 = g_ver;
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>    if ((! (ver0 & 1)) && (ver0 == ver1))
>>>>>>>>>>>    {
>>>>>>>>>>>       break;
>>>>>>>>>>>    }
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>    // A reader spun! Humm...
>>>>>>>>>>>    // yield, backoff, do something else
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> The pattern is read-mostly, write-rarely. Fast reads, slow
>>>>>>>>>>> writes. It works in user-land.
>>>>>>>>>>
>>>>>>>>>> Boy, you're so ultimately studpid.
>>>>>>>>>>
>>>>>>>>>> Readers could spin for a long time when whe writer is scheduled
>>>>>>>>>> away. So the approach of 1024 cores is not tolerable in userspace
>>>>>>>>>> and seqlocks only make sense in kernel space where the writer
>>>>>>>>>> could
>>>>>>>>>> disable scheduling while spinning of modifying.
>>>>>>>>>
>>>>>>>>> A writer never spins! God damn it. LOL!
>>>>>>>>
>>>>>>>> With this stupid 1024 cores implementation not.
>>>>>>>
>>>>>>> Huh? A traditional seqlock uses a lock for a writer. You really
>>>>>>> need to calm down and read about seqlocks.
>>>>>>
>>>>>> That's linux seqlock-structure:
>>>>>>
>>>>>> typedef struct {
>>>>>>      struct seqcount seqcount;
>>>>>>      spinlock_t lock;
>>>>>> } seqlock_t;
>>>>>>
>>>>>> Where's the mutex ?
>>>>>
>>>>> Humm... I am going to guess that the spinlock_t is the mutual
>>>>> exclusion lock here. LOL! Are you kidding me?
>>>>
>>>> spinlock_t is a spinlock, and not a mutex.
>>>> Linux kernel seqlocks don't include a mutex.
>>>
>>> Using a mutex in user land is fine! Using a seqlock with a mutex in
>>> userland is fine as long as your usage pattern fits in with
>>> read-mostly, write rarely.
>>
>> Using mutexes for "seqlocks" on the writer-side doesn't preserve the
>> readers from spinning. So seqlocks in user-space implmented in that
>> way are a strupid idea.
>>
>
> If course it does not prevent the readers from spinning. The readers
> can spin in the kernel as well. That's why the version count is there.


Click here to read the complete article
Re: Advanced (for me) Question About Keyword volatile

<svn0je$rsg$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20694&group=comp.lang.c#20694

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Tue, 1 Mar 2022 21:50:36 -0800
Organization: A noiseless patient Spider
Lines: 164
Message-ID: <svn0je$rsg$1@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me> <svmsfh$49c$1@dont-email.me>
<svmt1v$594$4@dont-email.me> <svmtp2$b27$2@dont-email.me>
<svmtvj$bja$3@dont-email.me> <svmu68$d2h$2@dont-email.me>
<svmu8i$e3q$2@dont-email.me> <svmubk$d2h$4@dont-email.me>
<svmusq$h8q$2@dont-email.me> <svmv4f$ioe$2@dont-email.me>
<svmvin$lb3$2@dont-email.me> <svmvv2$o5p$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Mar 2022 05:50:39 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d4a417dfd5e5fa43753e81c21b04ad49";
logging-data="28560"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/up1/0lWxc4MvgBeBvJp8uOyVXigEiCA0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:/qQWGHaJkYR6L3W8M7oVzcz/isc=
In-Reply-To: <svmvv2$o5p$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 2 Mar 2022 05:50 UTC

On 3/1/2022 9:39 PM, Bonita Montero wrote:
> Am 02.03.2022 um 06:33 schrieb Chris M. Thomasson:
>> On 3/1/2022 9:25 PM, Bonita Montero wrote:
>>> Am 02.03.2022 um 06:21 schrieb Chris M. Thomasson:
>>>> On 3/1/2022 9:12 PM, Bonita Montero wrote:
>>>>> Am 02.03.2022 um 06:10 schrieb Chris M. Thomasson:
>>>>>> On 3/1/2022 9:09 PM, Bonita Montero wrote:
>>>>>>> Am 02.03.2022 um 06:05 schrieb Chris M. Thomasson:
>>>>>>>> On 3/1/2022 9:02 PM, Bonita Montero wrote:
>>>>>>>>> Am 02.03.2022 um 05:50 schrieb Chris M. Thomasson:
>>>>>>>>>> On 3/1/2022 8:40 PM, Bonita Montero wrote:
>>>>>>>>>>> Am 02.03.2022 um 05:29 schrieb Chris M. Thomasson:
>>>>>>>>>>>> On 3/1/2022 8:12 PM, Bonita Montero wrote:
>>>>>>>>>>>>> Am 02.03.2022 um 04:54 schrieb Chris M. Thomasson:
>>>>>>>>>>>>>> On 3/1/2022 7:45 PM, Bonita Montero wrote:
>>>>>>>>>>>>>>> Am 01.03.2022 um 22:32 schrieb Chris M. Thomasson:
>>>>>>>>>>>>>>>> On 2/28/2022 11:51 PM, Bonita Montero wrote:
>>>>>>>>>>>>>>>>> Am 28.02.2022 um 01:14 schrieb Chris M. Thomasson:
>>>>>>>>>>>>>>>>>> On 2/27/2022 2:35 PM, das...@gmail.com wrote:
>>>>>>>>>>>>>>>>>>> I have 3 variables used as interface variables
>>>>>>>>>>>>>>>>>>> between 2 threads. Thread A writes the variables, and
>>>>>>>>>>>>>>>>>>> Thread B reads them.  Let me call them v1, v2, and v3.
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> I buffer (or snapshot) them into local variables.
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Question:  Do the local variables need to be declared
>>>>>>>>>>>>>>>>>>> volatile as well?
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> The local variables are fine, and do not need to be
>>>>>>>>>>>>>>>>>> atomic/volatile, ect... Btw, think about using C
>>>>>>>>>>>>>>>>>> atomic's instead of volatile. You might be interested
>>>>>>>>>>>>>>>>>> in a seqlock:
>>>>>>>>>>>>>>>>>> https://en.wikipedia.org/wiki/Seqlock
>>>>>>>>>>>>>>>>>> (read all)
>>>>>>>>>>>>>>>>>> They are geared to a read-mostly, write rarely pattern.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Seqlocks don't make sense in user-space as they're
>>>>>>>>>>>>>>>>> lock-free and
>>>>>>>>>>>>>>>>> a writer, having made the seq-counter odd, may be
>>>>>>>>>>>>>>>>> easily scheduled
>>>>>>>>>>>>>>>>> away before making the seq-counter even again.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Huh? The writers use a mutex. So, how lock-free is a
>>>>>>>>>>>>>>>> writer?
>>>>>>>>>>>>>>>> For some reason, I don't think you have ever used one.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Seqlocks need disabling the scheduler on a core while
>>>>>>>>>>>>>>> writing
>>>>>>>>>>>>>>> that a writer can't be scheduled away. That's not
>>>>>>>>>>>>>>> possible in
>>>>>>>>>>>>>>> user-mode.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Huh? Wow. This basically confirms that you have never used
>>>>>>>>>>>>>> a seqlock in user land. Remember that the writer uses a
>>>>>>>>>>>>>> normal mutex. Now, a friend of mine created a really neat
>>>>>>>>>>>>>> mutation of a seqlock:
>>>>>>>>>>>>>
>>>>>>>>>>>>> No, readers and writers spin.
>>>>>>>>>>>>> Otherwise you don't have a seq-lock but sth. different.
>>>>>>>>>>>>> Look how it is implemented in the Linux kernel.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> The basic seqlock minus the tricky membars:
>>>>>>>>>>>>
>>>>>>>>>>>> // quick and crude pseudo-code
>>>>>>>>>>>>
>>>>>>>>>>>> struct state { int a = 0; }
>>>>>>>>>>>> mutex g_lock;
>>>>>>>>>>>> atomic_unsigned g_ver = 0;
>>>>>>>>>>>>
>>>>>>>>>>>> state g_state;
>>>>>>>>>>>>
>>>>>>>>>>>> // writers
>>>>>>>>>>>> lock(g_lock);
>>>>>>>>>>>>    ++ver;
>>>>>>>>>>>>
>>>>>>>>>>>>      ++g_state.a;
>>>>>>>>>>>>
>>>>>>>>>>>>    ++ver;
>>>>>>>>>>>> unlock(g_lock);
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> // readers
>>>>>>>>>>>> state lstate;
>>>>>>>>>>>>
>>>>>>>>>>>> for (;;)
>>>>>>>>>>>> {
>>>>>>>>>>>>    unsigned ver0 = g_ver;
>>>>>>>>>>>>
>>>>>>>>>>>>      lstate = g_state;
>>>>>>>>>>>>
>>>>>>>>>>>>    unsigned ver1 = g_ver;
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>    if ((! (ver0 & 1)) && (ver0 == ver1))
>>>>>>>>>>>>    {
>>>>>>>>>>>>       break;
>>>>>>>>>>>>    }
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>    // A reader spun! Humm...
>>>>>>>>>>>>    // yield, backoff, do something else
>>>>>>>>>>>> }
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> The pattern is read-mostly, write-rarely. Fast reads, slow
>>>>>>>>>>>> writes. It works in user-land.
>>>>>>>>>>>
>>>>>>>>>>> Boy, you're so ultimately studpid.
>>>>>>>>>>>
>>>>>>>>>>> Readers could spin for a long time when whe writer is scheduled
>>>>>>>>>>> away. So the approach of 1024 cores is not tolerable in
>>>>>>>>>>> userspace
>>>>>>>>>>> and seqlocks only make sense in kernel space where the writer
>>>>>>>>>>> could
>>>>>>>>>>> disable scheduling while spinning of modifying.
>>>>>>>>>>
>>>>>>>>>> A writer never spins! God damn it. LOL!
>>>>>>>>>
>>>>>>>>> With this stupid 1024 cores implementation not.
>>>>>>>>
>>>>>>>> Huh? A traditional seqlock uses a lock for a writer. You really
>>>>>>>> need to calm down and read about seqlocks.
>>>>>>>
>>>>>>> That's linux seqlock-structure:
>>>>>>>
>>>>>>> typedef struct {
>>>>>>>      struct seqcount seqcount;
>>>>>>>      spinlock_t lock;
>>>>>>> } seqlock_t;
>>>>>>>
>>>>>>> Where's the mutex ?
>>>>>>
>>>>>> Humm... I am going to guess that the spinlock_t is the mutual
>>>>>> exclusion lock here. LOL! Are you kidding me?
>>>>>
>>>>> spinlock_t is a spinlock, and not a mutex.
>>>>> Linux kernel seqlocks don't include a mutex.
>>>>
>>>> Using a mutex in user land is fine! Using a seqlock with a mutex in
>>>> userland is fine as long as your usage pattern fits in with
>>>> read-mostly, write rarely.
>>>
>>> Using mutexes for "seqlocks" on the writer-side doesn't preserve the
>>> readers from spinning. So seqlocks in user-space implmented in that
>>> way are a strupid idea.
>>>
>>
>> If course it does not prevent the readers from spinning. The readers
>> can spin in the kernel as well. That's why the version count is there.
>
> *facepalm*
>
> Going to the kernel with a userland seqlock doesn't make it a seqlock
> any more.
> Seqlocks aren't possible in userspace. Spinning for a writer being
> scheduled away isn't tolerable. That's while seqlock inside th kernel
> disable the scheduler for a short while (by disabling interrupts) so
> that the readers always wait for the seqlock a very short time.


Click here to read the complete article
Re: Advanced (for me) Question About Keyword volatile

<svn0mf$rsu$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20695&group=comp.lang.c#20695

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Wed, 2 Mar 2022 06:52:19 +0100
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <svn0mf$rsu$1@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me> <svmsfh$49c$1@dont-email.me>
<svmt1v$594$4@dont-email.me> <svmtp2$b27$2@dont-email.me>
<svmtvj$bja$3@dont-email.me> <svmu68$d2h$2@dont-email.me>
<svmu8i$e3q$2@dont-email.me> <svmubk$d2h$4@dont-email.me>
<svmusq$h8q$2@dont-email.me> <svmv4f$ioe$2@dont-email.me>
<svmvin$lb3$2@dont-email.me> <svmvv2$o5p$1@dont-email.me>
<svn0je$rsg$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 05:52:15 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="28574"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19a7y2qrdpX9/T3F2X0lgwjqgO4oZiHK3I="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:XhKgJXVGlulvbveixq5sB0dIZcc=
In-Reply-To: <svn0je$rsg$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 05:52 UTC

> A seqlock in userland works fine. ...

Seqlocks in userspace a are a stupid idea. Having a writer that
can be scheduled away and thereby keep spinning a readers for a
long time isn't tolerable.

Re: Advanced (for me) Question About Keyword volatile

<svn47d$hvu$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20696&group=comp.lang.c#20696

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Tue, 1 Mar 2022 22:52:26 -0800
Organization: A noiseless patient Spider
Lines: 127
Message-ID: <svn47d$hvu$1@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Mar 2022 06:52:29 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d4a417dfd5e5fa43753e81c21b04ad49";
logging-data="18430"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/vZ2NjI8cWP3OWKYYavz9rDNGgHgiaz/A="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:yawuLjxTs39r2dBhr4DQrlqAk6s=
In-Reply-To: <svmrra$tr$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 2 Mar 2022 06:52 UTC

On 3/1/2022 8:29 PM, Chris M. Thomasson wrote:
> On 3/1/2022 8:12 PM, Bonita Montero wrote:
>> Am 02.03.2022 um 04:54 schrieb Chris M. Thomasson:
>>> On 3/1/2022 7:45 PM, Bonita Montero wrote:
>>>> Am 01.03.2022 um 22:32 schrieb Chris M. Thomasson:
>>>>> On 2/28/2022 11:51 PM, Bonita Montero wrote:
>>>>>> Am 28.02.2022 um 01:14 schrieb Chris M. Thomasson:
>>>>>>> On 2/27/2022 2:35 PM, das...@gmail.com wrote:
>>>>>>>> I have 3 variables used as interface variables between 2
>>>>>>>> threads. Thread A writes the variables, and Thread B reads
>>>>>>>> them.  Let me call them v1, v2, and v3.
>>>>>>>>
>>>>>>>> I buffer (or snapshot) them into local variables.
>>>>>>>>
>>>>>>>> Question:  Do the local variables need to be declared volatile
>>>>>>>> as well?
>>>>>>>
>>>>>>> The local variables are fine, and do not need to be
>>>>>>> atomic/volatile, ect... Btw, think about using C atomic's instead
>>>>>>> of volatile. You might be interested in a seqlock:
>>>>>>> https://en.wikipedia.org/wiki/Seqlock
>>>>>>> (read all)
>>>>>>> They are geared to a read-mostly, write rarely pattern.
>>>>>>
>>>>>> Seqlocks don't make sense in user-space as they're lock-free and
>>>>>> a writer, having made the seq-counter odd, may be easily scheduled
>>>>>> away before making the seq-counter even again.
>>>>>
>>>>> Huh? The writers use a mutex. So, how lock-free is a writer?
>>>>> For some reason, I don't think you have ever used one.
>>>>
>>>> Seqlocks need disabling the scheduler on a core while writing
>>>> that a writer can't be scheduled away. That's not possible in
>>>> user-mode.
>>>
>>> Huh? Wow. This basically confirms that you have never used a seqlock
>>> in user land. Remember that the writer uses a normal mutex. Now, a
>>> friend of mine created a really neat mutation of a seqlock:
>>
>> No, readers and writers spin.
>> Otherwise you don't have a seq-lock but sth. different.
>> Look how it is implemented in the Linux kernel.
>
>
> The basic seqlock minus the tricky membars:
>
> // quick and crude pseudo-code
>
> struct state { int a = 0; }
> mutex g_lock;
> atomic_unsigned g_ver = 0;
>
> state g_state;
>
> // writers
> lock(g_lock);
>   ++ver;
>
>     ++g_state.a;
>
>   ++ver;
> unlock(g_lock);
>
>
> // readers
> state lstate;
>

// ARGH!!!
____________________
> for (;;)
> {
>   unsigned ver0 = g_ver;
>
>     lstate = g_state;
>
>   unsigned ver1 = g_ver;
>
>
>   if ((! (ver0 & 1)) && (ver0 == ver1))
>   {
>      break;
>   }
>
>
>   // A reader spun! Humm...
>   // yield, backoff, do something else
> }
____________________

That should be:

____________________
for (;;)
{ unsigned ver0 = g_ver;

if (ver0 & 1)
{
// we spun on a locked state
continue;
}

lstate = g_state;

unsigned ver1 = g_ver;

if (ver0 == ver1)
{
break;
}

// A reader spun because the data was changed!
// Humm...
// yield, backoff, do something else
} ____________________

Sorry about that crap. That's what I get for quickly typing it out in
the damn newsreader. ;^o

>
> The pattern is read-mostly, write-rarely. Fast reads, slow writes. It
> works in user-land.

Re: Advanced (for me) Question About Keyword volatile

<svn49s$i4m$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20697&group=comp.lang.c#20697

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Wed, 2 Mar 2022 07:53:52 +0100
Organization: A noiseless patient Spider
Lines: 5
Message-ID: <svn49s$i4m$1@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me> <svn47d$hvu$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 06:53:48 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="18582"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18p43GKp4ubTiXHSzc3bHFMWynM9vphdNA="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:GFIzhrwUrNS2Gobllm4Yg1ZgzEE=
In-Reply-To: <svn47d$hvu$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 06:53 UTC

> Sorry about that crap. That's what I get for quickly typing it out in
> the damn newsreader. ;^o

No matter which implementation you chose - seqlocks in userspace
don't make any sense.

Re: Advanced (for me) Question About Keyword volatile

<svndrb$jiv$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20699&group=comp.lang.c#20699

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Advanced (for me) Question About Keyword volatile
Date: Wed, 2 Mar 2022 01:36:42 -0800
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <svndrb$jiv$2@dont-email.me>
References: <4eddd378-e045-4242-bf9e-bc0efae0cea5n@googlegroups.com>
<svh461$3jf$1@dont-email.me> <svkj9o$hqu$4@dont-email.me>
<svm3e0$3gj$1@dont-email.me> <svmp9f$hpc$1@dont-email.me>
<svmppj$l0t$1@dont-email.me> <svmqr5$qj0$1@dont-email.me>
<svmrra$tr$1@dont-email.me> <svmsfh$49c$1@dont-email.me>
<svmt1v$594$4@dont-email.me> <svmtp2$b27$2@dont-email.me>
<svmtvj$bja$3@dont-email.me> <svmu68$d2h$2@dont-email.me>
<svmu8i$e3q$2@dont-email.me> <svmubk$d2h$4@dont-email.me>
<svmusq$h8q$2@dont-email.me> <svmv4f$ioe$2@dont-email.me>
<svmvin$lb3$2@dont-email.me> <svmvv2$o5p$1@dont-email.me>
<svn0je$rsg$1@dont-email.me> <svn0mf$rsu$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 09:36:43 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d4a417dfd5e5fa43753e81c21b04ad49";
logging-data="20063"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sPCAVJZjazjGZI4mmF9E5iiAwQ3rE8LM="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:TN2wnvGpfFLq5/5EqM96MSYbz9w=
In-Reply-To: <svn0mf$rsu$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 2 Mar 2022 09:36 UTC

On 3/1/2022 9:52 PM, Bonita Montero wrote:
>> A seqlock in userland works fine. ...
>
> Seqlocks in userspace a are a stupid idea. Having a writer that
> can be scheduled away and thereby keep spinning a readers for a
> long time isn't tolerable.
>

Fwiw, I wrote a little experiment over on comp.lang.c++:

https://groups.google.com/g/comp.lang.c++/c/RYASx2cGqes/m/Cwv2WtG3BAAJ

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor