Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #89036

Re: timed_mutex -- but it acquires the lock

From "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups comp.lang.c++
Subject Re: timed_mutex -- but it acquires the lock
Date 2023-02-07 16:06 -0800
Organization A noiseless patient Spider
Message-ID <trup27$3u658$1@dont-email.me> (permalink)
References (3 earlier) <bd7cf957-c436-4739-adeb-30808de14393n@googlegroups.com> <truj2v$3tacv$1@dont-email.me> <d5f9db9b-53c6-42fe-bb16-0b527ec3089fn@googlegroups.com> <trukpo$3tgjl$3@dont-email.me> <eLAEL.662754$vBI8.580486@fx15.iad>

Show all headers | View raw


On 2/7/2023 3:01 PM, Scott Lurndal wrote:
> "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
>> On 2/7/2023 2:51 PM, Frederick Virchanza Gotham wrote:
>>> On Tuesday, February 7, 2023 at 10:24:47 PM UTC, Chris M. Thomasson wrote:
>>>
>>>> No. Not threads. Processes. If a thread dies in a process it will take
>>>> down the whole process.
>>>
>>> I used the following function:
>>>
>>>          https://man7.org/linux/man-pages/man3/pthread_mutexattr_setrobust.3.html
>>>
>>> Here's an excerpt:
>>>
>>>          "The robustness attribute specifies the behavior of the mutex when the owning thread dies without unlocking the mutex."
>>
>> If the owning thread dies, it means the process has died. robust mutexes
>> are for inter process sync.
> 
> The owning thread could exit (or be cancelled) without releasing the mutex
> and without killing the process.

Touche. Yeah, well, I was thinking of died as in seg fault without 
handling it. I have never had a use for the following:

https://linux.die.net/man/3/pthread_kill

Never had any use for pthread_cancel. I have only used robust mutexes 
for inter process communication. Using them for anything else is really 
strange to me. Threads just up and dying in a process is NOT kosher, in 
my humble opinion. However, a process dying is a different story.


> That said, I think the application should be designed such that robust
> mutexes are not required;  Just because a robust mutex automatically
> becomes unlocked - that doesn't prevent the state protected by the mutex
> from being partially updated and hence buggy when the robust mutex was released.
> 
> If the dead thread had been in the middle of a linked list update, for
> example, the list could end up with a loop or sans a bunch of entries.

Yup. Iirc, I had to do some tricky rollback operations back when I had 
to use them. A process dying had to be handled. I never had to rely on 
robust mutexes for intra process sync, only inter process.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

timed_mutex -- but it acquires the lock Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2023-02-07 01:25 -0800
  Re: timed_mutex -- but it acquires the lock Muttley@dastardlyhq.com - 2023-02-07 09:40 +0000
    Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-07 12:12 -0800
  Re: timed_mutex -- but it acquires the lock Bo Persson <bo@bo-persson.se> - 2023-02-07 10:48 +0100
    Re: timed_mutex -- but it acquires the lock Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2023-02-07 05:46 -0800
      Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-07 12:14 -0800
    Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-07 12:22 -0800
      Re: timed_mutex -- but it acquires the lock Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2023-02-07 14:17 -0800
        Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-07 14:24 -0800
          Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-07 14:49 -0800
          Re: timed_mutex -- but it acquires the lock Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2023-02-07 14:51 -0800
            Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-07 14:53 -0800
              Re: timed_mutex -- but it acquires the lock scott@slp53.sl.home (Scott Lurndal) - 2023-02-07 23:01 +0000
                Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-07 16:06 -0800
        Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-07 14:28 -0800
  Re: timed_mutex -- but it acquires the lock Paavo Helde <eesnimi@osa.pri.ee> - 2023-02-07 12:23 +0200
  Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-07 14:53 -0800
  Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-07 16:08 -0800
    Re: timed_mutex -- but it acquires the lock Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2023-02-08 10:37 -0800
      Re: timed_mutex -- but it acquires the lock Paavo Helde <eesnimi@osa.pri.ee> - 2023-02-08 20:52 +0200
        Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-08 12:37 -0800
        Re: timed_mutex -- but it acquires the lock Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2023-02-08 15:14 -0800
          Re: timed_mutex -- but it acquires the lock Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2023-02-08 17:33 -0800
          Re: timed_mutex -- but it acquires the lock Öö Tiib <ootiib@hot.ee> - 2023-02-08 17:45 -0800
          Re: timed_mutex -- but it acquires the lock David Brown <david.brown@hesbynett.no> - 2023-02-09 09:23 +0100
            Re: timed_mutex -- but it acquires the lock Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2023-02-09 01:24 -0800
              Re: timed_mutex -- but it acquires the lock Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2023-02-09 02:02 -0800
                Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-09 15:10 -0800
                Re: timed_mutex -- but it acquires the lock Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2023-02-10 08:06 -0800
                Re: timed_mutex -- but it acquires the lock David Brown <david.brown@hesbynett.no> - 2023-02-10 17:30 +0100
                Re: timed_mutex -- but it acquires the lock scott@slp53.sl.home (Scott Lurndal) - 2023-02-10 17:02 +0000
                Re: timed_mutex -- but it acquires the lock Richard Damon <Richard@Damon-Family.org> - 2023-02-10 20:02 -0500
                Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-17 12:58 -0800
                Re: timed_mutex -- but it acquires the lock Paavo Helde <eesnimi@osa.pri.ee> - 2023-02-10 20:57 +0200
          Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-09 04:02 -0800
            Re: timed_mutex -- but it acquires the lock Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2023-02-09 04:16 -0800
              Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-09 04:28 -0800
              Re: timed_mutex -- but it acquires the lock Paavo Helde <eesnimi@osa.pri.ee> - 2023-02-09 14:36 +0200
                Re: timed_mutex -- but it acquires the lock Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2023-02-09 08:34 -0800
                Re: timed_mutex -- but it acquires the lock David Brown <david.brown@hesbynett.no> - 2023-02-09 20:25 +0100
                Re: timed_mutex -- but it acquires the lock scott@slp53.sl.home (Scott Lurndal) - 2023-02-09 19:39 +0000
                Re: timed_mutex -- but it acquires the lock Paavo Helde <eesnimi@osa.pri.ee> - 2023-02-09 23:24 +0200
                Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-09 14:08 -0800
                Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-09 15:07 -0800
      Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-08 12:36 -0800
      Re: timed_mutex -- but it acquires the lock Paavo Helde <eesnimi@osa.pri.ee> - 2023-02-09 09:14 +0200
        Re: timed_mutex -- but it acquires the lock "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-09 14:17 -0800

csiph-web