|
|
Message-ID: <alpine.LNX.2.20.13.1706181257440.21867@monopod.intra.ispras.ru>
Date: Sun, 18 Jun 2017 13:01:18 +0300 (MSK)
From: Alexander Monakov <amonakov@...ras.ru>
To: musl@...ts.openwall.com
cc: Jens Gustedt <jens.gustedt@...ia.fr>
Subject: Re: [PATCH] a new lock algorithm with lock value and CS counts
in the same atomic int
On Fri, 16 Jun 2017, Jens Gustedt wrote:
> void __lock(volatile int *l)
> {
> - if (libc.threads_minus_1)
> - while (a_swap(l, 1)) __wait(l, l+1, 1, 1);
> + /* This test is mostly useless, now. Leaving it to the first CAS is
> + probably just as efficient. */
> + if (libc.threads_minus_1) {
[...]
> void __unlock(volatile int *l)
> {
> - if (l[0]) {
> - a_store(l, 0);
> - if (l[1]) __wake(l, 1, 1);
> + if (a_fetch_add(l, INT_MAX) != -INT_MAX) {
> + __syscall(SYS_futex, l, FUTEX_WAKE|FUTEX_PRIVATE, 1);
> }
> }
This looks wrong in single-threaded case, __lock doesn't touch the lock, but
__unlock modifies it unconditionally.
Alexander
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.