• condvar-implementation

    From Bonita Montero@21:1/5 to All on Mon Sep 20 20:44:10 2021
    A long time ago I found a page describing different approaches to imple-
    ment a condvar under Windows, but this would apply to any operating-sys-
    tem having parallelism through supplying semaphores and being designed
    for CPUs with atomic operations.
    I just wrote a special Java-like monitor-object for Win32 and __unix__.
    One speciality with my implementation is, that there's a method to
    signal the monitor (for a single or multiple threads) and relinquish
    ownership in one step. On Windows this only summarizes two atomic ope-
    rations in one, but on __unix__ I increase efficiency by using a SysV
    semaphore set and with semop I can raise two semaphores at once so
    that I save one kernel-call.
    A monitor object has the disadvantage that you can't signal multiple
    states to different threads with it - it's functionally like a single
    mutex bound to a single condvar. So I wrote a dual_monitor class which
    allows bidirectional communications of two threads bound to the same
    mutual exclusion. You cann call notify(_all)( bool b ) on it where b
    is a bool that says which state has to be signalled. Theres no prority
    on either direction and the threads are awakened in an arbitrary order.
    There's also a notify_(all_)and_unlock( bool b ) method that does the
    same signalling and unlocking in one step as for the first monitor.

    But I'm still interested in the paper which describes the different
    approaches in implementing a condvar for Win32. Maybe I can implement
    some improvemehts here also.
    Chris, I _only_ want this paper and no chaotic descriptions, salves
    of chaotic postings, or chaotic sourcecode. Your replies are usually
    no help at all.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Bonita Montero on Mon Sep 20 19:54:49 2021
    Bonita Montero <Bonita.Montero@gmail.com> writes:

    Chris, I _only_ want this paper and no chaotic descriptions, salves
    of chaotic postings, or chaotic sourcecode. Your replies are usually
    no help at all.

    Don't ask for help if you don't want answers that don't conform to your peculiar ideas of how things work.

    You might be better off querying a Windows-specific usenet newsgroup
    or other resources, if you can't stand to use the C++ language
    features defined in <mutex> and <condition_variable>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Mon Sep 20 15:52:46 2021
    On 9/20/2021 11:44 AM, Bonita Montero wrote:
    A long time ago I found a page describing different approaches to imple-
    ment a condvar under Windows, but this would apply to any operating-sys-
    tem having parallelism through supplying semaphores and being designed
    for CPUs with atomic operations.
    I just wrote a special Java-like monitor-object for Win32 and __unix__.
    One speciality with my implementation is, that there's a method to
    signal the monitor (for a single or multiple threads) and relinquish ownership in one step. On Windows this only summarizes two atomic ope- rations in one, but on __unix__ I increase efficiency by using a SysV semaphore set and with semop I can raise two semaphores at once so
    that I save one kernel-call.
    A monitor object has the disadvantage that you can't signal multiple
    states to different threads with it - it's functionally like a single
    mutex bound to a single condvar. So I wrote a dual_monitor class which
    allows bidirectional communications of two threads bound to the same
    mutual exclusion. You cann call notify(_all)( bool b ) on it where b
    is a bool that says which state has to be signalled. Theres no prority
    on either direction and the threads are awakened in an arbitrary order. There's also a notify_(all_)and_unlock( bool b ) method that does the
    same signalling and unlocking in one step as for the first monitor.

    But I'm still interested in the paper which describes the different approaches in implementing a condvar for Win32. Maybe I can implement
    some improvemehts here also.
    Chris, I _only_ want this paper and no chaotic descriptions, salves
    of chaotic postings, or chaotic sourcecode. Your replies are usually
    no help at all.

    Creating a working condvar can be very tricky. Have you tried to run
    your implementation through a race detector? Actually, iirc, using
    explicit waitsets works fine, however, they are bound to SCHED_OTHER.

    Take a look at the condvar impl in Pthreads-Win32:

    https://sourceware.org/pthreads-win32/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Tue Sep 21 13:24:44 2021
    Am 21.09.2021 um 00:52 schrieb Chris M. Thomasson:

    Creating a working condvar can be very tricky. Have you
    tried to run your implementation through a race detector? ...

    Can you read ? I haven't built a condvar but a monitor-object.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Tue Sep 21 16:08:30 2021
    On 9/21/2021 4:24 AM, Bonita Montero wrote:
    Am 21.09.2021 um 00:52 schrieb Chris M. Thomasson:

    Creating a working condvar can be very tricky. Have you
    tried to run  your implementation through a race detector? ...

    Can you read ? I haven't built a condvar but a monitor-object.

    I answered the part where you wrote:

    Bonita: But I'm still interested in the paper which describes the
    different approaches in implementing a condvar for Win32. Maybe I can
    implement some improvemehts here also.

    You snipped it out.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Tue Sep 21 16:33:59 2021
    On 9/21/2021 4:24 AM, Bonita Montero wrote:
    Am 21.09.2021 um 00:52 schrieb Chris M. Thomasson:

    Creating a working condvar can be very tricky. Have you
    tried to run  your implementation through a race detector? ...

    Can you read ? I haven't built a condvar but a monitor-object.

    A monitor object in C++ seems strange to me.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Chris M. Thomasson on Wed Sep 22 12:37:34 2021
    On 9/21/2021 4:08 PM, Chris M. Thomasson wrote:
    On 9/21/2021 4:24 AM, Bonita Montero wrote:
    Am 21.09.2021 um 00:52 schrieb Chris M. Thomasson:

    Creating a working condvar can be very tricky. Have you
    tried to run  your implementation through a race detector? ...

    Can you read ? I haven't built a condvar but a monitor-object.

    Also, can you read the subject of this thread: "condvar-implementation" ?



    I answered the part where you wrote:

    Bonita: But I'm still interested in the paper which describes the
    different approaches in implementing a condvar for Win32. Maybe I can implement some improvemehts here also.

    You snipped it out.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Thu Sep 23 06:18:07 2021
    Am 22.09.2021 um 21:37 schrieb Chris M. Thomasson:
    On 9/21/2021 4:08 PM, Chris M. Thomasson wrote:
    On 9/21/2021 4:24 AM, Bonita Montero wrote:
    Am 21.09.2021 um 00:52 schrieb Chris M. Thomasson:

    Creating a working condvar can be very tricky. Have you
    tried to run  your implementation through a race detector? ...

    Can you read ? I haven't built a condvar but a monitor-object.

    Also, can you read the subject of this thread: "condvar-implementation" ?



    I answered the part where you wrote:

    Bonita: But I'm still interested in the paper which describes the
    different approaches in implementing a condvar for Win32. Maybe I can
    implement some improvemehts here also.

    You snipped it out.

    You were referring to what I implemented so far.
    And this wasn't a condvar.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Wed Sep 22 22:23:46 2021
    On 9/22/2021 9:18 PM, Bonita Montero wrote:
    Am 22.09.2021 um 21:37 schrieb Chris M. Thomasson:
    On 9/21/2021 4:08 PM, Chris M. Thomasson wrote:
    On 9/21/2021 4:24 AM, Bonita Montero wrote:
    Am 21.09.2021 um 00:52 schrieb Chris M. Thomasson:

    Creating a working condvar can be very tricky. Have you
    tried to run  your implementation through a race detector? ...

    Can you read ? I haven't built a condvar but a monitor-object.

    Also, can you read the subject of this thread: "condvar-implementation" ?



    I answered the part where you wrote:

    Bonita: But I'm still interested in the paper which describes the
    different approaches in implementing a condvar for Win32. Maybe I can
    implement some improvemehts here also.

    You snipped it out.

    You were referring to what I implemented so far.
    And this wasn't a condvar.


    Its been a while Bonita. Heck, last time I used a monitor was WAY back
    when I was forced to work on some damn Java code, grrr. I was able to do
    the work, but did not really, "enjoy" it so to speak, argh.

    Actually, you are making me think back to a god damn horror show I had
    to debug where it turned out that somebody thought it was a good idea to
    use a condvar, with more than one mutex! My GOD!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Bonita Montero on Thu Sep 23 09:07:41 2021
    On 2021-09-23, Bonita Montero <Bonita.Montero@gmail.com> wrote:
    Am 22.09.2021 um 21:37 schrieb Chris M. Thomasson:
    On 9/21/2021 4:08 PM, Chris M. Thomasson wrote:
    On 9/21/2021 4:24 AM, Bonita Montero wrote:
    Am 21.09.2021 um 00:52 schrieb Chris M. Thomasson:

    Creating a working condvar can be very tricky. Have you
    tried to run  your implementation through a race detector? ...

    Can you read ? I haven't built a condvar but a monitor-object.

    Also, can you read the subject of this thread: "condvar-implementation" ?



    I answered the part where you wrote:

    Bonita: But I'm still interested in the paper which describes the
    different approaches in implementing a condvar for Win32. Maybe I can
    implement some improvemehts here also.

    You snipped it out.

    You were referring to what I implemented so far.
    And this wasn't a condvar.

    condvar assumes way to signal state, and upon receiveing
    signal to acquire lock, think about it.

    --
    7-77-777
    \|/
    ---
    /|\

    --
    /Volumes/air AFP Music Volume/NATASA/temp/peste noire/(2007) Folkfuck Folie/04 - D'un Vilain.mp3

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Thu Sep 23 09:09:42 2021
    On 2021-09-23, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 9/22/2021 9:18 PM, Bonita Montero wrote:
    Am 22.09.2021 um 21:37 schrieb Chris M. Thomasson:
    On 9/21/2021 4:08 PM, Chris M. Thomasson wrote:
    On 9/21/2021 4:24 AM, Bonita Montero wrote:
    Am 21.09.2021 um 00:52 schrieb Chris M. Thomasson:

    Creating a working condvar can be very tricky. Have you
    tried to run  your implementation through a race detector? ...

    Can you read ? I haven't built a condvar but a monitor-object.

    Also, can you read the subject of this thread: "condvar-implementation" ? >>>


    I answered the part where you wrote:

    Bonita: But I'm still interested in the paper which describes the
    different approaches in implementing a condvar for Win32. Maybe I can
    implement some improvemehts here also.

    You snipped it out.

    You were referring to what I implemented so far.
    And this wasn't a condvar.


    Its been a while Bonita. Heck, last time I used a monitor was WAY back
    when I was forced to work on some damn Java code, grrr. I was able to do
    the work, but did not really, "enjoy" it so to speak, argh.

    Actually, you are making me think back to a god damn horror show I had
    to debug where it turned out that somebody thought it was a good idea to
    use a condvar, with more than one mutex! My GOD!
    You can implement condvar via semaphore easilly and Windows has semaphores... Think about it...

    --
    7-77-777
    \|/
    ---
    /|\

    --
    /Volumes/air AFP Music Volume/NATASA/temp/peste noire/(2007) Folkfuck Folie/04 - D'un Vilain.mp3

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Thu Sep 23 19:06:41 2021
    Am 23.09.2021 um 07:23 schrieb Chris M. Thomasson:

    Actually, you are making me think back to a god damn horror show I had
    to debug where it turned out that somebody thought it was a good idea to
    use a condvar, with more than one mutex! My GOD!

    That's totally different from what I made. And what I made
    is a lot of work, but nothing completely difficult in detail.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Thu Sep 23 19:07:21 2021
    Am 23.09.2021 um 11:07 schrieb Branimir Maksimovic:
    On 2021-09-23, Bonita Montero <Bonita.Montero@gmail.com> wrote:
    Am 22.09.2021 um 21:37 schrieb Chris M. Thomasson:
    On 9/21/2021 4:08 PM, Chris M. Thomasson wrote:
    On 9/21/2021 4:24 AM, Bonita Montero wrote:
    Am 21.09.2021 um 00:52 schrieb Chris M. Thomasson:

    Creating a working condvar can be very tricky. Have you
    tried to run  your implementation through a race detector? ...

    Can you read ? I haven't built a condvar but a monitor-object.

    Also, can you read the subject of this thread: "condvar-implementation" ? >>>


    I answered the part where you wrote:

    Bonita: But I'm still interested in the paper which describes the
    different approaches in implementing a condvar for Win32. Maybe I can
    implement some improvemehts here also.

    You snipped it out.

    You were referring to what I implemented so far.
    And this wasn't a condvar.

    condvar assumes way to signal state, and upon receiveing
    signal to acquire lock, think about it.

    That's trivial to understand.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Thu Sep 23 10:28:41 2021
    On 9/23/2021 2:09 AM, Branimir Maksimovic wrote:
    On 2021-09-23, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 9/22/2021 9:18 PM, Bonita Montero wrote:
    Am 22.09.2021 um 21:37 schrieb Chris M. Thomasson:
    On 9/21/2021 4:08 PM, Chris M. Thomasson wrote:
    On 9/21/2021 4:24 AM, Bonita Montero wrote:
    Am 21.09.2021 um 00:52 schrieb Chris M. Thomasson:

    Creating a working condvar can be very tricky. Have you
    tried to run  your implementation through a race detector? ...

    Can you read ? I haven't built a condvar but a monitor-object.

    Also, can you read the subject of this thread: "condvar-implementation" ? >>>>


    I answered the part where you wrote:

    Bonita: But I'm still interested in the paper which describes the
    different approaches in implementing a condvar for Win32. Maybe I can >>>>> implement some improvemehts here also.

    You snipped it out.

    You were referring to what I implemented so far.
    And this wasn't a condvar.


    Its been a while Bonita. Heck, last time I used a monitor was WAY back
    when I was forced to work on some damn Java code, grrr. I was able to do
    the work, but did not really, "enjoy" it so to speak, argh.

    Actually, you are making me think back to a god damn horror show I had
    to debug where it turned out that somebody thought it was a good idea to
    use a condvar, with more than one mutex! My GOD!
    You can implement condvar via semaphore easilly and Windows has semaphores... Think about it...

    Well... Humm... Way back, a lot of people had condvar impls that are
    totally foobar. Not POSIX compliant and, iirc, a lot of them suffered
    from the dreaded "lost wakeup" syndrome, from time to time... Afaict,
    the really easy way is to use explicit waitsets. However, they have
    scheduling issues, sort of bound to SCHED_OTHER...

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