• Re: Signalling a condvar from inside and outside a locked mutex

    From Scott Lurndal@21:1/5 to Chris M. Thomasson on Fri Jul 19 19:05:02 2024
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 7/19/2024 9:26 AM, Bonita Montero wrote:
    [...]

    outside: 19937
    inside: 20030 100.471%

    Result: locking from inside and outside is as efficient with
    Linux and  glibc, only half a percent more contextswitches
    with locking from inside.

    Well, wait morphing should have something to do with it. ;^)

    Generally, signalling a condvar while the mutex is locked is not all
    that efficient...


    One cannot draw any conclusions from that toy example. It really
    depends on what percentage of the time there is contention on the
    mutex, how many waiters there are on average and the maturity of the
    host thread scheduler.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Bonita Montero on Sat Jul 20 14:30:12 2024
    Bonita Montero <Bonita.Montero@gmail.com> writes:
    Am 19.07.2024 um 21:05 schrieb Scott Lurndal:
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 7/19/2024 9:26 AM, Bonita Montero wrote:
    [...]

    outside: 19937
    inside: 20030 100.471%

    Result: locking from inside and outside is as efficient with
    Linux and  glibc, only half a percent more contextswitches
    with locking from inside.

    Well, wait morphing should have something to do with it. ;^)

    Generally, signalling a condvar while the mutex is locked is not all
    that efficient...


    One cannot draw any conclusions from that toy example. ...
    Show me the code that shows a difference.


    I have far better things to do with my time than argue with you.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marcel Mueller@21:1/5 to All on Sun Jul 21 14:14:57 2024
    Am 19.07.24 um 20:37 schrieb Chris M. Thomasson:
    Generally, signalling a condvar while the mutex is locked is not all
    that efficient...

    Is it?

    At least Java and AFAIK .NET throw an exception wenn notify is called
    w/o owning the mutex. pthread and std::condition_variable allow this
    scenario.
    Why this difference?

    Are the implementations of notify_one really likely to be lock-free?


    Marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)