• Tricky ...

    From Bonita Montero@21:1/5 to All on Mon Sep 20 22:43:45 2021
    In some code I've to check different sates for which an exception might
    be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    {
    uint64_t cmp = m_flagAndCounters.load( memory_order_relaxed ), chg;
    uint32_t visitors, aWaiters, bWaiters, waiters;
    assert(m_tid == thread_id::self());
    m_tid = thread_id();
    do
    {
    assert(isOwned( cmp ) && !m_recCount);
    visitors = getVisitors( cmp );
    aWaiters = getAWaiters( cmp );
    bWaiters = getAWaiters( cmp );
    assert(visitors >= aWaiters + bWaiters);
    waiters = !b ? aWaiters : bWaiters;

    static
    char const *const throwTable[] =
    {
    nullptr /* 0000 */, nullptr /* 0001 */, nullptr /* 0010 */,
    nullptr /* 0011 */, nullptr /* 0100 */, nullptr /* 0101 */,
    "monitor::wait() - number of visitors and a-waiters too large", // 0110
    "monitor::wait() - number of visitors and a-waiters too large", // 0111
    nullptr /* 1000 */, nullptr /* 1001 */, nullptr /* 1010 */,
    nullptr /* 1011 */, nullptr /* 1100 */,
    "monitor::wait() - number of visitors and b-waiters too large", // 1101
    nullptr, // 1110
    "monitor::wait() - number of visitors and b-waiters too large", // 1111
    };
    size_t maxVisitors = visitors == COUNTER_MASK,
    maxAWaiters = aWaiters == COUNTER_MASK,
    maxBWaiters = bWaiters == COUNTER_MASK;
    size_t throwIdx = (size_t)b << 3 | maxVisitors << 2 | maxAWaiters << 1
    | maxBWaiters;
    if( throwTable[throwIdx] )
    {
    m_tid = thread_id::self();
    throw out_of_range( throwTable[throwIdx] );
    };

    if( visitors > waiters )
    // waiters < COUNTER_MASK because visitors > waiters
    // taking over visitor-counter from another thread
    chg = cmp + (!b ? WAITER_A_VALUE : WAITER_B_VALUE);
    else
    // visitors == aWaiters + bWaiters
    chg = (cmp & ~OWNER_MASK) + (!b ? WAITER_A_VALUE : WAITER_B_VALUE) +
    VISITOR_VALUE;
    } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg, memory_order_release, memory_order_relaxed ) );
    if( visitors > waiters )
    {
    #if defined(_MSC_VER)
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );
    #elif defined(__unix__)
    sysv_semaphore::sembuf semBuf;
    do
    semBuf( VISITOR_SEM, 1, 0 );
    while( m_sems( &semBuf, 1, false ) == -1 );
    #endif
    }
    #if defined(_MSC_VER)
    HANDLE ahWait[2] = { (HANDLE)m_xhEvtVisit, (HANDLE)(!b ? m_xhSemWaitA : m_xhSemWaitB) };
    for( DWORD dwWait; (dwWait = WaitForMultipleObjects( 2, ahWait, TRUE, INFINITE )) < WAIT_OBJECT_0
    || dwWait > WAIT_OBJECT_0 + 1; );
    #elif defined(__unix__)
    sysv_semaphore::sembuf semBufs[2];
    do
    semBufs[0]( VISITOR_SEM, -1, 0 ),
    semBufs[1]( !b ? WAITER_A_SEM : WAITER_B_SEM, -1, 0 );
    while( m_sems( semBufs, 2, false ) == -1 );
    #endif
    m_tid = thread_id::self();
    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Thu Sep 23 10:38:55 2021
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might
    be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Please, try it out in a race detector? Create several programs that use
    your code in high load scenarios, and see what happens in the detector.
    Do we all have the time to examine your "tricky" code and test it out
    for ourselves? Well, not really. I am fairly busy with some fractal work
    right now. Sorry Bonita.

    Relacy is a good one, ThreadSanitizer is nice. My friend created Relacy,
    iirc, he is also working on ThreadSanitizer.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Thu Sep 23 20:30:30 2021
    Am 23.09.2021 um 20:29 schrieb Bonita Montero:
    Am 23.09.2021 um 19:38 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might
    be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Please, try it out in a race detector? Create several programs that
    use your code in high load scenarios, and see what happens in the
    detector. Do we all have the time to examine your "tricky" code and
    test it out for ourselves? Well, not really. I am fairly busy with
    some fractal work right now. Sorry Bonita.

    Not necessary. My montor works perfectly.
    I've implemented something completely new: a poll_wait operation.
    You simply supply a check-lambda that checks if there is valid state
    and my code repeatedly tries to lock the lock and check if the con-
    dition is true. The number of spins is re-calculated at each call
    according to the recalculation-pattern of the glibc.

    template<typename RetType, typename Predicate>
        requires requires( Predicate pred )
        {
            { pred() } -> std::same_as<std::pair<bool, RetType>>;
        }
    RetType monitor::wait_poll( Predicate const &pred )
    {
        using namespace std;
        using retpair_t = pair<bool, RetType>;
        uint32_t maxSpinT  = (uint32_t)m_nextPollSpinCount * 2 + 10;
        uint16_t maxSpin   = maxSpinT <= m_maxPollSpinCount ? (uint16_t)maxSpinT : m_maxPollSpinCount,
                 spinCount = 0;
        bool     notify    = false;
        uint64_t cmp       = m_flagAndCounters.load( memory_order_relaxed );
        for( ; !notify && spinCount < maxSpin; ++spinCount )
            if( isOwned( cmp ) )
            {
                cpu_pause( PAUSE_ITERATIONS );
                cmp = m_flagAndCounters.load( memory_order_relaxed );
                continue;
            }
            else if( m_flagAndCounters.compare_exchange_weak( cmp, cmp | OWNER_MASK, memory_order_acquire, memory_order_relaxed ) )
            {
                retpair_t ret = move( pred() );
                uint64_t chg;
                do
                {
                    uint32_t visitors = getVisitors( cmp ),
                             waiters  = getWaiters( cmp );
                    assert(visitors >= waiters);
                    chg = cmp & ~OWNER_MASK;
                    if( notify = visitors > waiters )
                        chg -= VISITOR_VALUE;
                } while( !m_flagAndCounters.compare_exchange_weak( cmp,
    chg, memory_order_relaxed, memory_order_relaxed ) );
                if( notify )
    #if defined(_MSC_VER)
                    while( !SetEvent( (HANDLE)m_xhEvtVisit ) ); #elif defined(__unix__)
                    for( m_sems( { sembuf( VISITOR_SEM, 1, 0 ) }, false )
    == -1 );
    #endif
                if( !ret.first )
                    if( !notify )
                        continue;
                    else
                        break;
                if( !notify )
                    m_nextPollSpinCount += (int16_t)(((int32_t)spinCount -
    (int32_t)m_nextPollSpinCount) / 8);
                return move( ret.second );
            }
            else
                cpu_pause( PAUSE_ITERATIONS );
        if( !notify )
            m_nextPollSpinCount += (int16_t)(((int32_t)spinCount - (int32_t)m_nextPollSpinCount) / 8);
        lock();
        try
        {
            for( ; ; )
            {
                retpair_t ret = move( pred() );
                if( ret.first )
                {
                    unlock();
                    return move( ret.second );
    Oh, I just thought that those two moves can be dropped since thei're
    implicit.
                }
                wait();
            }
        }
        catch( ... )
        {
            unlock();
            throw;
        }
    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Thu Sep 23 20:29:01 2021
    Am 23.09.2021 um 19:38 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might
    be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Please, try it out in a race detector? Create several programs that use
    your code in high load scenarios, and see what happens in the detector.
    Do we all have the time to examine your "tricky" code and test it out
    for ourselves? Well, not really. I am fairly busy with some fractal work right now. Sorry Bonita.

    Not necessary. My montor works perfectly.
    I've implemented something completely new: a poll_wait operation.
    You simply supply a check-lambda that checks if there is valid state
    and my code repeatedly tries to lock the lock and check if the con-
    dition is true. The number of spins is re-calculated at each call
    according to the recalculation-pattern of the glibc.

    template<typename RetType, typename Predicate>
    requires requires( Predicate pred )
    {
    { pred() } -> std::same_as<std::pair<bool, RetType>>;
    }
    RetType monitor::wait_poll( Predicate const &pred )
    {
    using namespace std;
    using retpair_t = pair<bool, RetType>;
    uint32_t maxSpinT = (uint32_t)m_nextPollSpinCount * 2 + 10;
    uint16_t maxSpin = maxSpinT <= m_maxPollSpinCount ? (uint16_t)maxSpinT : m_maxPollSpinCount,
    spinCount = 0;
    bool notify = false;
    uint64_t cmp = m_flagAndCounters.load( memory_order_relaxed );
    for( ; !notify && spinCount < maxSpin; ++spinCount )
    if( isOwned( cmp ) )
    {
    cpu_pause( PAUSE_ITERATIONS );
    cmp = m_flagAndCounters.load( memory_order_relaxed );
    continue;
    }
    else if( m_flagAndCounters.compare_exchange_weak( cmp, cmp | OWNER_MASK, memory_order_acquire, memory_order_relaxed ) )
    {
    retpair_t ret = move( pred() );
    uint64_t chg;
    do
    {
    uint32_t visitors = getVisitors( cmp ),
    waiters = getWaiters( cmp );
    assert(visitors >= waiters);
    chg = cmp & ~OWNER_MASK;
    if( notify = visitors > waiters )
    chg -= VISITOR_VALUE;
    } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg,
    memory_order_relaxed, memory_order_relaxed ) );
    if( notify )
    #if defined(_MSC_VER)
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) ); #elif defined(__unix__)
    for( m_sems( { sembuf( VISITOR_SEM, 1, 0 ) }, false ) == -1 );
    #endif
    if( !ret.first )
    if( !notify )
    continue;
    else
    break;
    if( !notify )
    m_nextPollSpinCount += (int16_t)(((int32_t)spinCount -
    (int32_t)m_nextPollSpinCount) / 8);
    return move( ret.second );
    }
    else
    cpu_pause( PAUSE_ITERATIONS );
    if( !notify )
    m_nextPollSpinCount += (int16_t)(((int32_t)spinCount - (int32_t)m_nextPollSpinCount) / 8);
    lock();
    try
    {
    for( ; ; )
    {
    retpair_t ret = move( pred() );
    if( ret.first )
    {
    unlock();
    return move( ret.second );
    }
    wait();
    }
    }
    catch( ... )
    {
    unlock();
    throw;
    }
    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Sep 24 18:48:24 2021
    On 9/23/2021 11:29 AM, Bonita Montero wrote:
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Humm....

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Chris M. Thomasson on Fri Sep 24 18:56:20 2021
    On 9/24/2021 6:48 PM, Chris M. Thomasson wrote:
    On 9/23/2021 11:29 AM, Bonita Montero wrote:
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Humm....

    For some damn reason, this reminds me of some broken condvar impls that
    used the good ol' PulseEvent:

    https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-pulseevent

    A quote: "This function is unreliable and should not be used. It exists
    mainly for backward compatibility. For more information, see Remarks."

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Sep 25 07:24:13 2021
    Am 25.09.2021 um 03:56 schrieb Chris M. Thomasson:
    On 9/24/2021 6:48 PM, Chris M. Thomasson wrote:
    On 9/23/2021 11:29 AM, Bonita Montero wrote:
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Humm....

    For some damn reason, this reminds me of some broken condvar impls that
    used the good ol' PulseEvent:

    https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-pulseevent


    A quote: "This function is unreliable and should not be used. It exists mainly for backward compatibility. For more information, see Remarks."

    What I do is reliable.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Bonita Montero on Sat Sep 25 12:28:47 2021
    On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:
    Am 25.09.2021 um 03:56 schrieb Chris M. Thomasson:
    On 9/24/2021 6:48 PM, Chris M. Thomasson wrote:
    On 9/23/2021 11:29 AM, Bonita Montero wrote:
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Humm....

    For some damn reason, this reminds me of some broken condvar impls that
    used the good ol' PulseEvent:

    https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-pulseevent


    A quote: "This function is unreliable and should not be used. It exists
    mainly for backward compatibility. For more information, see Remarks."

    What I do is reliable.

    This is because you SAY SO?



    --
    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Sep 25 15:57:56 2021
    Am 25.09.2021 um 14:28 schrieb Branimir Maksimovic:
    On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:
    Am 25.09.2021 um 03:56 schrieb Chris M. Thomasson:
    On 9/24/2021 6:48 PM, Chris M. Thomasson wrote:
    On 9/23/2021 11:29 AM, Bonita Montero wrote:
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Humm....

    For some damn reason, this reminds me of some broken condvar impls that
    used the good ol' PulseEvent:

    https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-pulseevent


    A quote: "This function is unreliable and should not be used. It exists
    mainly for backward compatibility. For more information, see Remarks."

    What I do is reliable.

    This is because you SAY SO?

    Inspect my code and say why it is not instead of making
    arbitrary assumptions.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Sep 25 16:09:04 2021
    Am 25.09.2021 um 15:59 schrieb Branimir Maksimovic:
    On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:
    What I do is reliable.

    This is because you SAY SO?

    Inspect my code and say why it is not instead of making
    arbitrary assumptions.

    Show your code, I missed it :(

    I showed my wait_poll-function. It's sth. completely new that improves
    most usualy monitor-handling, usually with producer-consumer patterns
    where the mutex-part of the monitor is held very short.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Bonita Montero on Sat Sep 25 13:59:04 2021
    On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:
    What I do is reliable.

    This is because you SAY SO?

    Inspect my code and say why it is not instead of making
    arbitrary assumptions.

    Show your code, I missed it :(


    --
    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Bonita Montero on Sat Sep 25 17:13:27 2021
    On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:
    Am 25.09.2021 um 15:59 schrieb Branimir Maksimovic:
    On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:
    What I do is reliable.

    This is because you SAY SO?

    Inspect my code and say why it is not instead of making
    arbitrary assumptions.

    Show your code, I missed it :(

    I showed my wait_poll-function. It's sth. completely new that improves
    most usualy monitor-handling, usually with producer-consumer patterns
    where the mutex-part of the monitor is held very short.

    And you use unreliable function for that?
    --

    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Sep 25 19:15:39 2021
    Am 25.09.2021 um 19:13 schrieb Branimir Maksimovic:
    On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:
    Am 25.09.2021 um 15:59 schrieb Branimir Maksimovic:
    On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:
    What I do is reliable.

    This is because you SAY SO?

    Inspect my code and say why it is not instead of making
    arbitrary assumptions.

    Show your code, I missed it :(

    I showed my wait_poll-function. It's sth. completely new that improves
    most usualy monitor-handling, usually with producer-consumer patterns
    where the mutex-part of the monitor is held very short.

    And you use unreliable function for that?

    Show me where my code is unreliable.
    I think you're simply a poor troll.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Bonita Montero on Sat Sep 25 17:22:05 2021
    On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:

    And you use unreliable function for that?

    Show me where my code is unreliable.
    I think you're simply a poor troll.
    I am just asking because you build something
    on shaken ground. Why do you think is reliable,
    simple question?

    --

    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Sat Sep 25 13:34:06 2021
    On 9/24/2021 10:24 PM, Bonita Montero wrote:
    Am 25.09.2021 um 03:56 schrieb Chris M. Thomasson:
    On 9/24/2021 6:48 PM, Chris M. Thomasson wrote:
    On 9/23/2021 11:29 AM, Bonita Montero wrote:
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Humm....

    For some damn reason, this reminds me of some broken condvar impls
    that used the good ol' PulseEvent:

    https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-pulseevent


    A quote: "This function is unreliable and should not be used. It
    exists mainly for backward compatibility. For more information, see
    Remarks."

    What I do is reliable.


    Whats up with the:

    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Shouldn't you use GetLastError to find out why SetEvent failed?

    Also, you are using:

    cpu_pause( PAUSE_ITERATIONS );

    In several places? Reeks of a spinlock. Some kind of backoff?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sun Sep 26 05:48:58 2021
    Am 25.09.2021 um 22:34 schrieb Chris M. Thomasson:
    On 9/24/2021 10:24 PM, Bonita Montero wrote:
    Am 25.09.2021 um 03:56 schrieb Chris M. Thomasson:
    On 9/24/2021 6:48 PM, Chris M. Thomasson wrote:
    On 9/23/2021 11:29 AM, Bonita Montero wrote:
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Humm....

    For some damn reason, this reminds me of some broken condvar impls
    that used the good ol' PulseEvent:

    https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-pulseevent


    A quote: "This function is unreliable and should not be used. It
    exists mainly for backward compatibility. For more information, see
    Remarks."

    What I do is reliable.


    Whats up with the:

    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Shouldn't you use GetLastError to find out why SetEvent failed?

    No, once I incremented the waiter or visitor count I can't set it back
    because it might have been reduced by someone awakening me. So I've to
    spin or terminate the program. But this doesn't matter since SE fails
    under conditions where the machine almost has no resources.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sun Sep 26 05:46:29 2021
    Am 25.09.2021 um 19:22 schrieb Branimir Maksimovic:
    On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:

    And you use unreliable function for that?

    Show me where my code is unreliable.
    I think you're simply a poor troll.
    I am just asking because you build something
    on shaken ground. Why do you think is reliable,
    simple question?

    Because the code is simple.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Mon Sep 27 00:18:23 2021
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might
    be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    {
        uint64_t cmp = m_flagAndCounters.load( memory_order_relaxed ), chg;
        uint32_t visitors, aWaiters, bWaiters, waiters;
        assert(m_tid == thread_id::self());
        m_tid = thread_id();
        do
        {
            assert(isOwned( cmp ) && !m_recCount);
            visitors = getVisitors( cmp );
            aWaiters = getAWaiters( cmp );
            bWaiters = getAWaiters( cmp );
            assert(visitors >= aWaiters + bWaiters);
            waiters  = !b ? aWaiters : bWaiters;

            static
            char const *const throwTable[] =
            {
                nullptr /* 0000 */, nullptr /* 0001 */, nullptr /* 0010 */,
                nullptr /* 0011 */, nullptr /* 0100 */, nullptr /* 0101 */,
                "monitor::wait() - number of visitors and a-waiters too
    large", // 0110
                "monitor::wait() - number of visitors and a-waiters too
    large", // 0111
                nullptr /* 1000 */, nullptr /* 1001 */, nullptr /* 1010 */,
                nullptr /* 1011 */, nullptr /* 1100 */,
                "monitor::wait() - number of visitors and b-waiters too
    large", // 1101
                nullptr, // 1110
                "monitor::wait() - number of visitors and b-waiters too
    large", // 1111
            };
            size_t maxVisitors = visitors == COUNTER_MASK,
                   maxAWaiters = aWaiters == COUNTER_MASK,
                   maxBWaiters = bWaiters == COUNTER_MASK;
            size_t throwIdx = (size_t)b << 3 | maxVisitors << 2 | maxAWaiters << 1 | maxBWaiters;
            if( throwTable[throwIdx] )
            {
                m_tid = thread_id::self();
                throw out_of_range( throwTable[throwIdx] );
            };

            if( visitors > waiters )
                // waiters < COUNTER_MASK because visitors > waiters
                // taking over visitor-counter from another thread
                chg = cmp + (!b ? WAITER_A_VALUE : WAITER_B_VALUE);
            else
                // visitors == aWaiters + bWaiters
                chg = (cmp & ~OWNER_MASK) + (!b ? WAITER_A_VALUE : WAITER_B_VALUE) + VISITOR_VALUE;
        } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg, memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for std::memory_order_acq_rel
    here wrt the cas. Humm... I need to port your algorihtm over to a form
    that Relacy can understand. Its been a while! I just got a strange
    feeling. Waiting is usually, acquire semantics. Humm... Sorry, need to
    examine it further, and port it over. Then run it in certain scenarios.
    Relacy has the capability to crack it wide open if there are any issues.

    I should have some time later on tomorrow. I am busy with my fractal
    software right now:

    https://fractalforums.org/gallery/1612-270921004032.jpeg

    http://siggrapharts.ning.com/photo/alien-anatomy

    lol. ;^)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Mon Sep 27 14:44:30 2021
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might
    be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    {
         uint64_t cmp = m_flagAndCounters.load( memory_order_relaxed ), chg;
         uint32_t visitors, aWaiters, bWaiters, waiters;
         assert(m_tid == thread_id::self());
         m_tid = thread_id();
         do
         {
             assert(isOwned( cmp ) && !m_recCount);
             visitors = getVisitors( cmp );
             aWaiters = getAWaiters( cmp );
             bWaiters = getAWaiters( cmp );
             assert(visitors >= aWaiters + bWaiters);
             waiters  = !b ? aWaiters : bWaiters;

             static
             char const *const throwTable[] =
             {
                 nullptr /* 0000 */, nullptr /* 0001 */, nullptr /* 0010 */,
                 nullptr /* 0011 */, nullptr /* 0100 */, nullptr /* 0101 */,
                 "monitor::wait() - number of visitors and a-waiters too
    large", // 0110
                 "monitor::wait() - number of visitors and a-waiters too
    large", // 0111
                 nullptr /* 1000 */, nullptr /* 1001 */, nullptr /* 1010 */,
                 nullptr /* 1011 */, nullptr /* 1100 */,
                 "monitor::wait() - number of visitors and b-waiters too
    large", // 1101
                 nullptr, // 1110
                 "monitor::wait() - number of visitors and b-waiters too
    large", // 1111
             };
             size_t maxVisitors = visitors == COUNTER_MASK,
                    maxAWaiters = aWaiters == COUNTER_MASK,
                    maxBWaiters = bWaiters == COUNTER_MASK;
             size_t throwIdx = (size_t)b << 3 | maxVisitors << 2 |
    maxAWaiters << 1 | maxBWaiters;
             if( throwTable[throwIdx] )
             {
                 m_tid = thread_id::self();
                 throw out_of_range( throwTable[throwIdx] );
             };

             if( visitors > waiters )
                 // waiters < COUNTER_MASK because visitors > waiters
                 // taking over visitor-counter from another thread >>              chg = cmp + (!b ? WAITER_A_VALUE : WAITER_B_VALUE); >>          else
                 // visitors == aWaiters + bWaiters
                 chg = (cmp & ~OWNER_MASK) + (!b ? WAITER_A_VALUE : >> WAITER_B_VALUE) + VISITOR_VALUE;
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg,
    memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for std::memory_order_acq_rel
    here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From red floyd@21:1/5 to Bonita Montero on Mon Sep 27 10:54:31 2021
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    [redacted]

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    If you're going to ask for opinions and then reject any criticism
    as nonsense, then why the heck are you even bothering to post your
    code?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to red floyd on Mon Sep 27 14:10:13 2021
    On 9/27/2021 10:54 AM, red floyd wrote:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    [redacted]

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    If you're going to ask for opinions and then reject any criticism
    as nonsense, then why the heck are you even bothering to post your
    code?

    Yeah, no shi%. Wow. Fwiw, its been a while since I have worked on such
    things. I just need to port Bonita's code over to Relacy, and give it a
    go in the simulator. It can find obscure memory order issues pretty damn
    fast. The problem is that I need to find the time. I mean, Bonita is not
    paying me. ;^)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Mon Sep 27 14:06:21 2021
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might
    be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg,
    memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for std::memory_order_acq_rel
    here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics. Incrementing a
    semaphore requires release semantics. Trying to do both at once in a
    single atomic operation requires acquire/release semantics.

    I still need to port it to Relacy, but it seems like you need acq_rel here.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Chris M. Thomasson on Mon Sep 27 16:09:18 2021
    On 9/27/2021 2:06 PM, Chris M. Thomasson wrote:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might >>>> be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg, >>>> memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for std::memory_order_acq_rel
    here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics. Incrementing a
    semaphore requires release semantics. Trying to do both at once in a
    single atomic operation requires acquire/release semantics.

    I still need to port it to Relacy, but it seems like you need acq_rel here.

    Think about it... Waiting for something, implies acquire semantics.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Tue Sep 28 06:55:49 2021
    Am 27.09.2021 um 23:06 schrieb Chris M. Thomasson:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might >>>> be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg, >>>> memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for std::memory_order_acq_rel
    here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics.

    No, I could have modified data before, so I need, release-semantics.
    You are such a n00b.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Tue Sep 28 06:57:27 2021
    Am 28.09.2021 um 01:09 schrieb Chris M. Thomasson:
    On 9/27/2021 2:06 PM, Chris M. Thomasson wrote:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception
    might
    be thrown. These states are all true or false so I combined them to a >>>>> four bit pattern wich I used as an index to a table which stores the >>>>> strings of the out_of_range exception to be trown or a nullptr if the >>>>> state isn't associated with an out of range condition. This helps me >>>>> to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the >>>>> code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg, >>>>> memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for
    std::memory_order_acq_rel here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics. Incrementing a
    semaphore requires release semantics. Trying to do both at once in a
    single atomic operation requires acquire/release semantics.

    I still need to port it to Relacy, but it seems like you need acq_rel
    here.

    Think about it... Waiting for something, implies acquire semantics.

    No, when I release a lock and could have modified data,
    I need release-semantics.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Mon Sep 27 22:28:25 2021
    On 9/27/2021 9:57 PM, Bonita Montero wrote:
    Am 28.09.2021 um 01:09 schrieb Chris M. Thomasson:
    On 9/27/2021 2:06 PM, Chris M. Thomasson wrote:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception
    might
    be thrown. These states are all true or false so I combined them to a >>>>>> four bit pattern wich I used as an index to a table which stores the >>>>>> strings of the out_of_range exception to be trown or a nullptr if the >>>>>> state isn't associated with an out of range condition. This helps me >>>>>> to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the >>>>>> code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg, >>>>>> memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for
    std::memory_order_acq_rel here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics. Incrementing a
    semaphore requires release semantics. Trying to do both at once in a
    single atomic operation requires acquire/release semantics.

    I still need to port it to Relacy, but it seems like you need acq_rel
    here.

    Think about it... Waiting for something, implies acquire semantics.

    No, when I release a lock and could have modified data,
    I need release-semantics.

    So, how can one utilize dual_monitor::wait? Does it wait on something?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Mon Sep 27 22:27:26 2021
    On 9/27/2021 9:55 PM, Bonita Montero wrote:
    Am 27.09.2021 um 23:06 schrieb Chris M. Thomasson:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception
    might
    be thrown. These states are all true or false so I combined them to a >>>>> four bit pattern wich I used as an index to a table which stores the >>>>> strings of the out_of_range exception to be trown or a nullptr if the >>>>> state isn't associated with an out of range condition. This helps me >>>>> to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the >>>>> code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg, >>>>> memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for
    std::memory_order_acq_rel here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics.

    No, I could have modified data before, so I need, release-semantics.
    You are such a n00b.

    For some reason when I saw the word "wait", I think of acquire. Are you
    sure you know all about memory barriers? I have worked with them in the
    past.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Mon Sep 27 22:46:49 2021
    On 9/25/2021 8:48 PM, Bonita Montero wrote:
    Am 25.09.2021 um 22:34 schrieb Chris M. Thomasson:
    On 9/24/2021 10:24 PM, Bonita Montero wrote:
    Am 25.09.2021 um 03:56 schrieb Chris M. Thomasson:
    On 9/24/2021 6:48 PM, Chris M. Thomasson wrote:
    On 9/23/2021 11:29 AM, Bonita Montero wrote:
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Humm....

    For some damn reason, this reminds me of some broken condvar impls
    that used the good ol' PulseEvent:

    https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-pulseevent


    A quote: "This function is unreliable and should not be used. It
    exists mainly for backward compatibility. For more information, see
    Remarks."

    What I do is reliable.


    Whats up with the:

    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Shouldn't you use GetLastError to find out why SetEvent failed?

    No, once I incremented the waiter or visitor count I can't set it back because it might have been reduced by someone awakening me. So I've to
    spin or terminate the program.

    Terminate? Humm... If there are conditions arising in the system in
    which SetEvent fails, you go into infinite loop here, right? Try to
    handle this scenario. Find out why it failed, GetLastError.


    But this doesn't matter since SE fails
    under conditions where the machine almost has no resources.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Chris M. Thomasson on Mon Sep 27 22:49:31 2021
    On 9/27/2021 10:27 PM, Chris M. Thomasson wrote:
    On 9/27/2021 9:55 PM, Bonita Montero wrote:
    Am 27.09.2021 um 23:06 schrieb Chris M. Thomasson:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception
    might
    be thrown. These states are all true or false so I combined them to a >>>>>> four bit pattern wich I used as an index to a table which stores the >>>>>> strings of the out_of_range exception to be trown or a nullptr if the >>>>>> state isn't associated with an out of range condition. This helps me >>>>>> to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the >>>>>> code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg, >>>>>> memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for
    std::memory_order_acq_rel here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics.

    No, I could have modified data before, so I need, release-semantics.
    You are such a n00b.

    Waiting on something is acquire by nature. Show me where its not?
    Actually, show me where to place the acquire and release barriers in a semaphore? Can you do it? Should be a piece of cake, right?


    For some reason when I saw the word "wait", I think of acquire. Are you
    sure you know all about memory barriers? I have worked with them in the
    past.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Tue Sep 28 08:33:49 2021
    Am 28.09.2021 um 07:28 schrieb Chris M. Thomasson:
    On 9/27/2021 9:57 PM, Bonita Montero wrote:
    Am 28.09.2021 um 01:09 schrieb Chris M. Thomasson:
    On 9/27/2021 2:06 PM, Chris M. Thomasson wrote:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception >>>>>>> might
    be thrown. These states are all true or false so I combined them >>>>>>> to a
    four bit pattern wich I used as an index to a table which stores the >>>>>>> strings of the out_of_range exception to be trown or a nullptr if >>>>>>> the
    state isn't associated with an out of range condition. This helps me >>>>>>> to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around >>>>>>> the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg, >>>>>>> memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for
    std::memory_order_acq_rel here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics. Incrementing a
    semaphore requires release semantics. Trying to do both at once in a
    single atomic operation requires acquire/release semantics.

    I still need to port it to Relacy, but it seems like you need
    acq_rel here.

    Think about it... Waiting for something, implies acquire semantics.

    No, when I release a lock and could have modified data,
    I need release-semantics.

    So, how can one utilize dual_monitor::wait? Does it wait on something?

    Its like waiting on a condvar, which might have modified any data
    before.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Tue Sep 28 08:34:40 2021
    Am 28.09.2021 um 07:46 schrieb Chris M. Thomasson:
    On 9/25/2021 8:48 PM, Bonita Montero wrote:
    Am 25.09.2021 um 22:34 schrieb Chris M. Thomasson:
    On 9/24/2021 10:24 PM, Bonita Montero wrote:
    Am 25.09.2021 um 03:56 schrieb Chris M. Thomasson:
    On 9/24/2021 6:48 PM, Chris M. Thomasson wrote:
    On 9/23/2021 11:29 AM, Bonita Montero wrote:
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Humm....

    For some damn reason, this reminds me of some broken condvar impls
    that used the good ol' PulseEvent:

    https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-pulseevent


    A quote: "This function is unreliable and should not be used. It
    exists mainly for backward compatibility. For more information, see
    Remarks."

    What I do is reliable.


    Whats up with the:

    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Shouldn't you use GetLastError to find out why SetEvent failed?

    No, once I incremented the waiter or visitor count I can't set it back
    because it might have been reduced by someone awakening me. So I've to
    spin or terminate the program.

    Terminate? Humm... If there are conditions arising in the system in
    which SetEvent fails, you go into infinite loop here, right? Try to
    handle this scenario. Find out why it failed, GetLastError.

    If the system hasn't any resources to satisfy a simple WaitForSingle... spinning is quite o.k..

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Tue Sep 28 00:03:30 2021
    On 9/27/2021 11:33 PM, Bonita Montero wrote:
    Am 28.09.2021 um 07:28 schrieb Chris M. Thomasson:
    On 9/27/2021 9:57 PM, Bonita Montero wrote:
    Am 28.09.2021 um 01:09 schrieb Chris M. Thomasson:
    On 9/27/2021 2:06 PM, Chris M. Thomasson wrote:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an
    exception might
    be thrown. These states are all true or false so I combined them >>>>>>>> to a
    four bit pattern wich I used as an index to a table which stores >>>>>>>> the
    strings of the out_of_range exception to be trown or a nullptr >>>>>>>> if the
    state isn't associated with an out of range condition. This
    helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines
    around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, >>>>>>>> chg, memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for
    std::memory_order_acq_rel here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics. Incrementing a
    semaphore requires release semantics. Trying to do both at once in
    a single atomic operation requires acquire/release semantics.

    I still need to port it to Relacy, but it seems like you need
    acq_rel here.

    Think about it... Waiting for something, implies acquire semantics.

    No, when I release a lock and could have modified data,
    I need release-semantics.

    So, how can one utilize dual_monitor::wait? Does it wait on something?

    Its like waiting on a condvar, which might have modified any data
    before.


    I was thinking along those lines. However, waiting on a condvar involves several steps. It also involves reacquiring the mutex...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Tue Sep 28 00:05:30 2021
    On 9/27/2021 11:34 PM, Bonita Montero wrote:
    Am 28.09.2021 um 07:46 schrieb Chris M. Thomasson:
    On 9/25/2021 8:48 PM, Bonita Montero wrote:
    Am 25.09.2021 um 22:34 schrieb Chris M. Thomasson:
    On 9/24/2021 10:24 PM, Bonita Montero wrote:
    Am 25.09.2021 um 03:56 schrieb Chris M. Thomasson:
    On 9/24/2021 6:48 PM, Chris M. Thomasson wrote:
    On 9/23/2021 11:29 AM, Bonita Montero wrote:
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Humm....

    For some damn reason, this reminds me of some broken condvar impls >>>>>> that used the good ol' PulseEvent:

    https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-pulseevent


    A quote: "This function is unreliable and should not be used. It
    exists mainly for backward compatibility. For more information,
    see Remarks."

    What I do is reliable.


    Whats up with the:

    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Shouldn't you use GetLastError to find out why SetEvent failed?

    No, once I incremented the waiter or visitor count I can't set it back
    because it might have been reduced by someone awakening me. So I've to
    spin or terminate the program.

    Terminate? Humm... If there are conditions arising in the system in
    which SetEvent fails, you go into infinite loop here, right? Try to
    handle this scenario. Find out why it failed, GetLastError.

    If the system hasn't any resources to satisfy a simple WaitForSingle... spinning is quite o.k..


    spinning indeed. However, you have no backoff. You are spinning full speed!


    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Oh shit. When shit hits the fan, so does this! Try to not bleed the
    system when its in dire straights?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Tue Sep 28 00:06:24 2021
    On 9/27/2021 11:33 PM, Bonita Montero wrote:
    Am 28.09.2021 um 07:27 schrieb Chris M. Thomasson:
    On 9/27/2021 9:55 PM, Bonita Montero wrote:
    Am 27.09.2021 um 23:06 schrieb Chris M. Thomasson:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception >>>>>>> might
    be thrown. These states are all true or false so I combined them >>>>>>> to a
    four bit pattern wich I used as an index to a table which stores the >>>>>>> strings of the out_of_range exception to be trown or a nullptr if >>>>>>> the
    state isn't associated with an out of range condition. This helps me >>>>>>> to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around >>>>>>> the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg, >>>>>>> memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for
    std::memory_order_acq_rel here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics.

    No, I could have modified data before, so I need, release-semantics.
    You are such a n00b.

    For some reason when I saw the word "wait", I think of acquire. Are
    you sure you know all about memory barriers? ...

    Everything necessary here.


    For sure?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Tue Sep 28 12:06:30 2021
    Am 28.09.2021 um 09:05 schrieb Chris M. Thomasson:
    On 9/27/2021 11:34 PM, Bonita Montero wrote:
    Am 28.09.2021 um 07:46 schrieb Chris M. Thomasson:
    On 9/25/2021 8:48 PM, Bonita Montero wrote:
    Am 25.09.2021 um 22:34 schrieb Chris M. Thomasson:
    On 9/24/2021 10:24 PM, Bonita Montero wrote:
    Am 25.09.2021 um 03:56 schrieb Chris M. Thomasson:
    On 9/24/2021 6:48 PM, Chris M. Thomasson wrote:
    On 9/23/2021 11:29 AM, Bonita Montero wrote:
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Humm....

    For some damn reason, this reminds me of some broken condvar
    impls that used the good ol' PulseEvent:

    https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-pulseevent


    A quote: "This function is unreliable and should not be used. It >>>>>>> exists mainly for backward compatibility. For more information,
    see Remarks."

    What I do is reliable.


    Whats up with the:

    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );

    Shouldn't you use GetLastError to find out why SetEvent failed?

    No, once I incremented the waiter or visitor count I can't set it back >>>> because it might have been reduced by someone awakening me. So I've to >>>> spin or terminate the program.

    Terminate? Humm... If there are conditions arising in the system in
    which SetEvent fails, you go into infinite loop here, right? Try to
    handle this scenario. Find out why it failed, GetLastError.

    If the system hasn't any resources to satisfy a simple WaitForSingle...
    spinning is quite o.k..


    spinning indeed. However, you have no backoff. You are spinning full speed! while( !SetEvent( (HANDLE)m_xhEvtVisit ) );
    Oh shit. When shit hits the fan, so does this! Try to not bleed the
    system when its in dire straights?

    That doesnt't matter under such conditions.
    Am I talking to a complete moron here ?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Tue Sep 28 12:05:26 2021
    Am 28.09.2021 um 09:03 schrieb Chris M. Thomasson:
    On 9/27/2021 11:33 PM, Bonita Montero wrote:
    Am 28.09.2021 um 07:28 schrieb Chris M. Thomasson:
    On 9/27/2021 9:57 PM, Bonita Montero wrote:
    Am 28.09.2021 um 01:09 schrieb Chris M. Thomasson:
    On 9/27/2021 2:06 PM, Chris M. Thomasson wrote:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an
    exception might
    be thrown. These states are all true or false so I combined
    them to a
    four bit pattern wich I used as an index to a table which
    stores the
    strings of the out_of_range exception to be trown or a nullptr >>>>>>>>> if the
    state isn't associated with an out of range condition. This
    helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines
    around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, >>>>>>>>> chg, memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for
    std::memory_order_acq_rel here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics. Incrementing
    a semaphore requires release semantics. Trying to do both at once
    in a single atomic operation requires acquire/release semantics.

    I still need to port it to Relacy, but it seems like you need
    acq_rel here.

    Think about it... Waiting for something, implies acquire semantics.

    No, when I release a lock and could have modified data,
    I need release-semantics.

    So, how can one utilize dual_monitor::wait? Does it wait on something?

    Its like waiting on a condvar, which might have modified any data
    before.


    I was thinking along those lines. However, waiting on a condvar involves several steps. It also involves reacquiring the mutex...

    With what I do the reacquisition is done by the side that unlocks the
    mutex. It simply keeps the locked-flag while unlocking and sets the visitor-event.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Bonita Montero on Tue Sep 28 16:05:46 2021
    On 28/09/2021 12:06, Bonita Montero wrote:
    Am 28.09.2021 um 09:05 schrieb Chris M. Thomasson:
    On 9/27/2021 11:34 PM, Bonita Montero wrote:

    If the system hasn't any resources to satisfy a simple WaitForSingle...
    spinning is quite o.k..


    spinning indeed. However, you have no backoff. You are spinning full
    speed!
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );
    Oh shit. When shit hits the fan, so does this! Try to not bleed the
    system when its in dire straights?

    That doesnt't matter under such conditions.
    Am I talking to a complete moron here ?

    Chris, why do you keep trying to communicate with Bonita? She is
    clearly so convinced of her own superiority to everyone else that it is pointless. She does not post code for people to check, she posts it
    because she thinks she is showing off and impressing people. This kind
    of code is difficult to get right, and any capable developer is going to
    want to discuss it with people to check the details. Since Bonita
    responds with nothing but insults and arrogance, I think it is safe to
    assume her code is flawed and leave her with it.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Tue Sep 28 18:46:37 2021
    Am 28.09.2021 um 16:05 schrieb David Brown:
    On 28/09/2021 12:06, Bonita Montero wrote:
    Am 28.09.2021 um 09:05 schrieb Chris M. Thomasson:
    On 9/27/2021 11:34 PM, Bonita Montero wrote:

    If the system hasn't any resources to satisfy a simple WaitForSingle... >>>> spinning is quite o.k..


    spinning indeed. However, you have no backoff. You are spinning full
    speed!
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );
    Oh shit. When shit hits the fan, so does this! Try to not bleed the
    system when its in dire straights?

    That doesnt't matter under such conditions.
    Am I talking to a complete moron here ?

    Chris, why do you keep trying to communicate with Bonita? She is
    clearly so convinced of her own superiority to everyone else that it is pointless. She does not post code for people to check, she posts it
    because she thinks she is showing off and impressing people. This kind
    of code is difficult to get right, and any capable developer is going to
    want to discuss it with people to check the details. Since Bonita
    responds with nothing but insults and arrogance, I think it is safe to
    assume her code is flawed and leave her with it.

    Chris doesn't understand my code. He even doesn't understand that before
    any wait-operations you use atomic operations with release consistency
    and after you use atomic operations with acquire-consistency. He is
    totally confused.
    And with the above code: once a visitor has incremented the visitor
    -counter it can't decrement it because it might have decremented by
    the code wanting to wake up a visitor. So under extreme conditions
    where the system doesn't have the least resources to satisfy such a
    simple operations spinning is quite o.k. until the conditions become
    better. The system isn't usable anyway then.
    It's simply frustrating to explain such simple things. Chris is simply
    a n00b which lacks basic knowledge.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Tue Sep 28 14:02:41 2021
    On 9/28/2021 9:46 AM, Bonita Montero wrote:
    Am 28.09.2021 um 16:05 schrieb David Brown:
    On 28/09/2021 12:06, Bonita Montero wrote:
    Am 28.09.2021 um 09:05 schrieb Chris M. Thomasson:
    On 9/27/2021 11:34 PM, Bonita Montero wrote:

    If the system hasn't any resources to satisfy a simple
    WaitForSingle...
    spinning is quite o.k..


    spinning indeed. However, you have no backoff. You are spinning full
    speed!
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );
    Oh shit. When shit hits the fan, so does this! Try to not bleed the
    system when its in dire straights?

    That doesnt't matter under such conditions.
    Am I talking to a complete moron here ?

    Chris, why do you keep trying to communicate with Bonita?  She is
    clearly so convinced of her own superiority to everyone else that it is
    pointless.  She does not post code for people to check, she posts it
    because she thinks she is showing off and impressing people.  This kind
    of code is difficult to get right, and any capable developer is going to
    want to discuss it with people to check the details.  Since Bonita
    responds with nothing but insults and arrogance, I think it is safe to
    assume her code is flawed and leave her with it.

    Chris doesn't understand my code. He even doesn't understand that before
    any wait-operations you use atomic operations with release consistency
    and after you use atomic operations with acquire-consistency. He is
    totally confused.

    Ummm... WOW. You are confused, Big time. I already asked you to show me
    exactly where to place the memory barriers necessary to implement a
    semaphore. Can you do it? I can. Show me... I am interested to see if
    you can do it. From what you are writing, I don't think you can. Oh
    well. Shit happens.


    And with the above code: once a visitor has incremented the visitor
    -counter it can't decrement it because it might have decremented by
    the code wanting to wake up a visitor. So under extreme conditions
    where the system doesn't have the least resources to satisfy such a
    simple operations spinning is quite o.k. until the conditions become
    better. The system isn't usable anyway then.
    It's simply frustrating to explain such simple things. Chris is simply
    a n00b which lacks basic knowledge.

    lol. Humm... Perhaps I should just leave you with it. You refuse to run
    it through a race detector... Why? I was going to port it over to
    Relacy, but now... Argh. Screw it. You do it.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to David Brown on Tue Sep 28 14:42:01 2021
    On 9/28/2021 7:05 AM, David Brown wrote:
    On 28/09/2021 12:06, Bonita Montero wrote:
    Am 28.09.2021 um 09:05 schrieb Chris M. Thomasson:
    On 9/27/2021 11:34 PM, Bonita Montero wrote:

    If the system hasn't any resources to satisfy a simple WaitForSingle... >>>> spinning is quite o.k..


    spinning indeed. However, you have no backoff. You are spinning full
    speed!
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );
    Oh shit. When shit hits the fan, so does this! Try to not bleed the
    system when its in dire straights?

    That doesnt't matter under such conditions.
    Am I talking to a complete moron here ?

    Chris, why do you keep trying to communicate with Bonita? She is
    clearly so convinced of her own superiority to everyone else that it is pointless. She does not post code for people to check, she posts it
    because she thinks she is showing off and impressing people. This kind
    of code is difficult to get right, and any capable developer is going to
    want to discuss it with people to check the details. Since Bonita
    responds with nothing but insults and arrogance, I think it is safe to
    assume her code is flawed and leave her with it.


    Yeah. Damn. She does not seem to know a whole lot about memory barriers,
    those tricky bastards! ;^) I was trying to help her. Then I get spit on.
    I asked her a simple question: Where do the memory barriers go for a
    semaphore. So far, no answer. She is confused. Calling me a newb is
    strange because I have been working with these types of things for decades.

    I would love to see Bonita program a SPARC in RMO mode. That would be amusing... Actually Sun gave me a SunFire T2000 after winning the first
    round in their CoolThreads contest. My project was called vZOOM. That
    damn server sounded like several vacuum cleaners running when I was
    working with it.

    I wonder if she knows what a #LoadStore | #LoadLoad barrier is. That
    MEMBAR instruction was fun on the SPARC. ;^)

    So, I will just shut up, and let her do her thing.

    Oh well.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From red floyd@21:1/5 to Chris M. Thomasson on Tue Sep 28 17:05:02 2021
    On 9/28/2021 2:42 PM, Chris M. Thomasson wrote:

    working with it.

    I wonder if she knows what a #LoadStore | #LoadLoad barrier is. That
    MEMBAR instruction was fun on the SPARC. ;^)


    Not quite a membar, but on PowerPC, the EIEIO instruction was also fun.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to red floyd on Tue Sep 28 19:28:32 2021
    On 9/28/2021 5:05 PM, red floyd wrote:
    On 9/28/2021 2:42 PM, Chris M. Thomasson wrote:

    working with it.

    I wonder if she knows what a #LoadStore | #LoadLoad barrier is. That
    MEMBAR instruction was fun on the SPARC. ;^)


    Not quite a membar, but on PowerPC, the EIEIO instruction was also fun.


    Yup. Iirc, it was for IO. Its been a while since I programmed a PPC. I
    wrote about some of the pitfalls of using LL/SC on it a while back on comp.arch:

    https://groups.google.com/g/comp.arch/c/yREvvvKvr6k/m/nRZ5tpLwDNQJ

    Wow, this was way back in 2005! Jeeze! ;^o

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Wed Sep 29 02:31:44 2021
    On 2021-09-28, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 9/27/2021 10:27 PM, Chris M. Thomasson wrote:
    On 9/27/2021 9:55 PM, Bonita Montero wrote:
    Am 27.09.2021 um 23:06 schrieb Chris M. Thomasson:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception >>>>>>> might
    be thrown. These states are all true or false so I combined them to a >>>>>>> four bit pattern wich I used as an index to a table which stores the >>>>>>> strings of the out_of_range exception to be trown or a nullptr if the >>>>>>> state isn't associated with an out of range condition. This helps me >>>>>>> to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the >>>>>>> code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg, >>>>>>> memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for
    std::memory_order_acq_rel here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics.

    No, I could have modified data before, so I need, release-semantics.
    You are such a n00b.

    Waiting on something is acquire by nature. Show me where its not?
    Actually, show me where to place the acquire and release barriers in a semaphore? Can you do it? Should be a piece of cake, right?


    semaphore wait then acquire

    --

    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to David Brown on Wed Sep 29 02:32:36 2021
    On 2021-09-28, David Brown <david.brown@hesbynett.no> wrote:
    On 28/09/2021 12:06, Bonita Montero wrote:
    Am 28.09.2021 um 09:05 schrieb Chris M. Thomasson:
    On 9/27/2021 11:34 PM, Bonita Montero wrote:

    If the system hasn't any resources to satisfy a simple WaitForSingle... >>>> spinning is quite o.k..


    spinning indeed. However, you have no backoff. You are spinning full
    speed!
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );
    Oh shit. When shit hits the fan, so does this! Try to not bleed the
    system when its in dire straights?

    That doesnt't matter under such conditions.
    Am I talking to a complete moron here ?

    Chris, why do you keep trying to communicate with Bonita? She is
    clearly so convinced of her own superiority to everyone else that it is pointless. She does not post code for people to check, she posts it
    because she thinks she is showing off and impressing people. This kind
    of code is difficult to get right, and any capable developer is going to
    want to discuss it with people to check the details. Since Bonita
    responds with nothing but insults and arrogance, I think it is safe to
    assume her code is flawed and leave her with it.
    She is clever, but newb. Forgive her for that.

    --

    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Tue Sep 28 20:14:55 2021
    On 9/28/2021 7:31 PM, Branimir Maksimovic wrote:
    On 2021-09-28, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 9/27/2021 10:27 PM, Chris M. Thomasson wrote:
    On 9/27/2021 9:55 PM, Bonita Montero wrote:
    Am 27.09.2021 um 23:06 schrieb Chris M. Thomasson:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception >>>>>>>> might
    be thrown. These states are all true or false so I combined them to a >>>>>>>> four bit pattern wich I used as an index to a table which stores the >>>>>>>> strings of the out_of_range exception to be trown or a nullptr if the >>>>>>>> state isn't associated with an out of range condition. This helps me >>>>>>>> to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the >>>>>>>> code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, chg,
    memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for
    std::memory_order_acq_rel here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released,
    so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics.

    No, I could have modified data before, so I need, release-semantics.
    You are such a n00b.

    Waiting on something is acquire by nature. Show me where its not?
    Actually, show me where to place the acquire and release barriers in a
    semaphore? Can you do it? Should be a piece of cake, right?


    semaphore wait then acquire


    Yup! You got it. I like how C++ has standalone membars via std::atomic_thread_fence. Makes me reminisce about the SPARC where all
    atomic ops are naked, or relaxed in C++ terms. An acquire on the SPARC
    was MEMBAR #LoadStore | #LoadLoad, ah the good ol' days. ;^)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to red floyd on Wed Sep 29 08:35:15 2021
    On 29/09/2021 02:05, red floyd wrote:
    On 9/28/2021 2:42 PM, Chris M. Thomasson wrote:

    working with it.

    I wonder if she knows what a #LoadStore | #LoadLoad barrier is. That
    MEMBAR instruction was fun on the SPARC. ;^)


    The most challenging architecture, AFAIK, was the Alpha. (I have no
    experience of it myself.)


    Not quite a membar, but on PowerPC, the EIEIO instruction was also fun.


    It is certainly the best named instruction around!

    It was useful on early PPC microcontroller cores, to avoid unwanted
    reordering or buffering of accesses to hardware registers. Later cores
    had an MPU that supported setting up memory areas for direct unbuffered accesses, which is a more convenient and safer method.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Wed Sep 29 12:41:08 2021
    Am 28.09.2021 um 23:42 schrieb Chris M. Thomasson:

    Yeah. Damn. She does not seem to know a whole lot about memory barriers,

    I use them a lot and correctly.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Wed Sep 29 12:42:21 2021
    Am 29.09.2021 um 08:35 schrieb David Brown:

    The most challenging architecture, AFAIK, was the Alpha.

    The Alpha isn't challenging because it has the most relaxed memory
    -ordering of all CPUs: If there would be a C++11-compiler for the
    alpha you would use conventional membars and the code virtually
    executes like on every other CPU.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Wed Sep 29 12:05:10 2021
    On 9/29/2021 3:41 AM, Bonita Montero wrote:
    Am 28.09.2021 um 23:42 schrieb Chris M. Thomasson:

    Yeah. Damn. She does not seem to know a whole lot about memory barriers,

    I use them a lot and correctly.


    A wait on a semaphore does not need release semantics. It only needs
    acquire.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Wed Sep 29 12:09:54 2021
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might
    be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Have you posted the whole dual_monitor code? If you did, I missed it.
    Sorry.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Wed Sep 29 12:04:21 2021
    On 9/29/2021 3:42 AM, Bonita Montero wrote:
    Am 29.09.2021 um 08:35 schrieb David Brown:

    The most challenging architecture, AFAIK, was the Alpha.

    The Alpha isn't challenging because it has the most relaxed memory
    -ordering of all CPUs: If there would be a C++11-compiler for the
    alpha you would use conventional membars and the code virtually
    executes like on every other CPU.

    Oh my. You cannot even implement the read side of RCU without a damn
    membar on an Alpha! You don't think that is challenging at all? I don't
    think you ever implemented RCU. Also, have you implemented SMR? That
    actually requires an explicit membar on an x86! Joe Seigh came up with a
    way to combine RCU and SMR to get rid of the membar by putting SMR in a
    read side RCU critical section. It improved the performance of loading a
    SMR pointer by orders of magnitude. Well done Joe.

    :^)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Wed Sep 29 12:05:24 2021
    On 9/28/2021 7:32 PM, Branimir Maksimovic wrote:
    On 2021-09-28, David Brown <david.brown@hesbynett.no> wrote:
    On 28/09/2021 12:06, Bonita Montero wrote:
    Am 28.09.2021 um 09:05 schrieb Chris M. Thomasson:
    On 9/27/2021 11:34 PM, Bonita Montero wrote:

    If the system hasn't any resources to satisfy a simple WaitForSingle... >>>>> spinning is quite o.k..


    spinning indeed. However, you have no backoff. You are spinning full
    speed!
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );
    Oh shit. When shit hits the fan, so does this! Try to not bleed the
    system when its in dire straights?

    That doesnt't matter under such conditions.
    Am I talking to a complete moron here ?

    Chris, why do you keep trying to communicate with Bonita? She is
    clearly so convinced of her own superiority to everyone else that it is
    pointless. She does not post code for people to check, she posts it
    because she thinks she is showing off and impressing people. This kind
    of code is difficult to get right, and any capable developer is going to
    want to discuss it with people to check the details. Since Bonita
    responds with nothing but insults and arrogance, I think it is safe to
    assume her code is flawed and leave her with it.
    She is clever, but newb. Forgive her for that.


    She is clever.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Wed Sep 29 18:43:54 2021
    On 9/29/2021 6:33 PM, Bonita Montero wrote:
    Am 29.09.2021 um 21:05 schrieb Chris M. Thomasson:
    On 9/29/2021 3:41 AM, Bonita Montero wrote:
    Am 28.09.2021 um 23:42 schrieb Chris M. Thomasson:

    Yeah. Damn. She does not seem to know a whole lot about memory
    barriers,

    I use them a lot and correctly.


    A wait on a semaphore does not need release semantics. ...

    It needs because I could have modiefied data before releasing the
    lock I'm waiting for just at the same time.


    So, it needs acquire release, right?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Thu Sep 30 03:33:42 2021
    Am 29.09.2021 um 21:05 schrieb Chris M. Thomasson:
    On 9/29/2021 3:41 AM, Bonita Montero wrote:
    Am 28.09.2021 um 23:42 schrieb Chris M. Thomasson:

    Yeah. Damn. She does not seem to know a whole lot about memory barriers,

    I use them a lot and correctly.


    A wait on a semaphore does not need release semantics. ...

    It needs because I could have modiefied data before releasing the
    lock I'm waiting for just at the same time.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Wed Sep 29 19:47:00 2021
    On 9/29/2021 6:33 PM, Bonita Montero wrote:
    Am 29.09.2021 um 21:05 schrieb Chris M. Thomasson:
    On 9/29/2021 3:41 AM, Bonita Montero wrote:
    Am 28.09.2021 um 23:42 schrieb Chris M. Thomasson:

    Yeah. Damn. She does not seem to know a whole lot about memory
    barriers,

    I use them a lot and correctly.


    A wait on a semaphore does not need release semantics. ...

    It needs because I could have modiefied data before releasing the
    lock I'm waiting for just at the same time.


    Have you posted all of your code for dual_monitor? Or just
    dual_monitor::wait?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Wed Sep 29 21:57:16 2021
    On 9/28/2021 3:05 AM, Bonita Montero wrote:
    Am 28.09.2021 um 09:03 schrieb Chris M. Thomasson:
    On 9/27/2021 11:33 PM, Bonita Montero wrote:
    Am 28.09.2021 um 07:28 schrieb Chris M. Thomasson:
    On 9/27/2021 9:57 PM, Bonita Montero wrote:
    Am 28.09.2021 um 01:09 schrieb Chris M. Thomasson:
    On 9/27/2021 2:06 PM, Chris M. Thomasson wrote:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an
    exception might
    be thrown. These states are all true or false so I combined >>>>>>>>>> them to a
    four bit pattern wich I used as an index to a table which
    stores the
    strings of the out_of_range exception to be trown or a nullptr >>>>>>>>>> if the
    state isn't associated with an out of range condition. This >>>>>>>>>> helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines >>>>>>>>>> around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, >>>>>>>>>> chg, memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for
    std::memory_order_acq_rel here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released, >>>>>>>> so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics. Incrementing >>>>>>> a semaphore requires release semantics. Trying to do both at once >>>>>>> in a single atomic operation requires acquire/release semantics. >>>>>>>
    I still need to port it to Relacy, but it seems like you need
    acq_rel here.

    Think about it... Waiting for something, implies acquire semantics. >>>>>
    No, when I release a lock and could have modified data,
    I need release-semantics.

    So, how can one utilize dual_monitor::wait? Does it wait on something?

    Its like waiting on a condvar, which might have modified any data
    before.


    I was thinking along those lines. However, waiting on a condvar
    involves several steps. It also involves reacquiring the mutex...

    With what I do the reacquisition is done by the side that unlocks the
    mutex. It simply keeps the locked-flag while unlocking and sets the visitor-event.

    Where are your example use cases for dual_monitor? I cannot find all of
    the code for dual_monitor anyway. So, its difficult for me to port to a simulator and use... Just make a new thread, with an example program
    that uses dual_monitor.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Bonita Montero on Thu Sep 30 09:10:41 2021
    On 30/09/2021 03:33, Bonita Montero wrote:
    Am 29.09.2021 um 21:05 schrieb Chris M. Thomasson:
    On 9/29/2021 3:41 AM, Bonita Montero wrote:
    Am 28.09.2021 um 23:42 schrieb Chris M. Thomasson:

    Yeah. Damn. She does not seem to know a whole lot about memory
    barriers,

    I use them a lot and correctly.


    A wait on a semaphore does not need release semantics. ...

    It needs because I could have modiefied data before releasing the
    lock I'm waiting for just at the same time.


    If you release a lock, you need release semantics. If you acquire a
    lock, you need acquire semantics.

    There is a lot of fiddly stuff in getting memory barriers and
    synchronisation right - and a lot of /really/ tough stuff in getting it
    right and optimally efficient on big processors. But "acquire" and
    "release" semantics are helpfully named!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Thu Sep 30 08:16:36 2021
    Am 30.09.2021 um 06:57 schrieb Chris M. Thomasson:
    On 9/28/2021 3:05 AM, Bonita Montero wrote:
    Am 28.09.2021 um 09:03 schrieb Chris M. Thomasson:
    On 9/27/2021 11:33 PM, Bonita Montero wrote:
    Am 28.09.2021 um 07:28 schrieb Chris M. Thomasson:
    On 9/27/2021 9:57 PM, Bonita Montero wrote:
    Am 28.09.2021 um 01:09 schrieb Chris M. Thomasson:
    On 9/27/2021 2:06 PM, Chris M. Thomasson wrote:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an
    exception might
    be thrown. These states are all true or false so I combined >>>>>>>>>>> them to a
    four bit pattern wich I used as an index to a table which >>>>>>>>>>> stores the
    strings of the out_of_range exception to be trown or a
    nullptr if the
    state isn't associated with an out of range condition. This >>>>>>>>>>> helps me
    to prevent some if-else-cascades and speeds up the code. >>>>>>>>>>> So this is the complete function but i put two empty lines >>>>>>>>>>> around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, >>>>>>>>>>> chg, memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for
    std::memory_order_acq_rel here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released, >>>>>>>>> so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics.
    Incrementing a semaphore requires release semantics. Trying to >>>>>>>> do both at once in a single atomic operation requires
    acquire/release semantics.

    I still need to port it to Relacy, but it seems like you need
    acq_rel here.

    Think about it... Waiting for something, implies acquire semantics. >>>>>>
    No, when I release a lock and could have modified data,
    I need release-semantics.

    So, how can one utilize dual_monitor::wait? Does it wait on something? >>>>
    Its like waiting on a condvar, which might have modified any data
    before.


    I was thinking along those lines. However, waiting on a condvar
    involves several steps. It also involves reacquiring the mutex...

    With what I do the reacquisition is done by the side that unlocks the
    mutex. It simply keeps the locked-flag while unlocking and sets the
    visitor-event.

    Where are your example use cases for dual_monitor? ...

    It's usable when two threads communicate bidirectional.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Thu Sep 30 01:19:21 2021
    On 9/29/2021 11:16 PM, Bonita Montero wrote:
    Am 30.09.2021 um 06:57 schrieb Chris M. Thomasson:
    On 9/28/2021 3:05 AM, Bonita Montero wrote:
    Am 28.09.2021 um 09:03 schrieb Chris M. Thomasson:
    On 9/27/2021 11:33 PM, Bonita Montero wrote:
    Am 28.09.2021 um 07:28 schrieb Chris M. Thomasson:
    On 9/27/2021 9:57 PM, Bonita Montero wrote:
    Am 28.09.2021 um 01:09 schrieb Chris M. Thomasson:
    On 9/27/2021 2:06 PM, Chris M. Thomasson wrote:
    On 9/27/2021 5:44 AM, Bonita Montero wrote:
    Am 27.09.2021 um 09:18 schrieb Chris M. Thomasson:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an >>>>>>>>>>>> exception might
    be thrown. These states are all true or false so I combined >>>>>>>>>>>> them to a
    four bit pattern wich I used as an index to a table which >>>>>>>>>>>> stores the
    strings of the out_of_range exception to be trown or a >>>>>>>>>>>> nullptr if the
    state isn't associated with an out of range condition. This >>>>>>>>>>>> helps me
    to prevent some if-else-cascades and speeds up the code. >>>>>>>>>>>> So this is the complete function but i put two empty lines >>>>>>>>>>>> around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]
         } while( !m_flagAndCounters.compare_exchange_weak( cmp, >>>>>>>>>>>> chg, memory_order_release, memory_order_relaxed ) );
    [...]

    Humm... For some reason I feel the need for
    std::memory_order_acq_rel here wrt the cas. ...

    No, you only write nonsense. When I wait the lock is released, >>>>>>>>>> so it's release-consistency.

    You always write nonsense.

    Decrementing a semaphore requires acquire semantics.
    Incrementing a semaphore requires release semantics. Trying to >>>>>>>>> do both at once in a single atomic operation requires
    acquire/release semantics.

    I still need to port it to Relacy, but it seems like you need >>>>>>>>> acq_rel here.

    Think about it... Waiting for something, implies acquire semantics. >>>>>>>
    No, when I release a lock and could have modified data,
    I need release-semantics.

    So, how can one utilize dual_monitor::wait? Does it wait on
    something?

    Its like waiting on a condvar, which might have modified any data
    before.


    I was thinking along those lines. However, waiting on a condvar
    involves several steps. It also involves reacquiring the mutex...

    With what I do the reacquisition is done by the side that unlocks the
    mutex. It simply keeps the locked-flag while unlocking and sets the
    visitor-event.

    Where are your example use cases for dual_monitor? ...

    It's usable when two threads communicate bidirectional.

    That's a bit vague. One can create highly efficient bidirectional
    communication between two threads using two wait-free single-producer/single-consumer queues without using any atomic RMW's,
    just atomic loads, stores, and some some cleverly placed membars. Now,
    if one needs to be able to wait on them, well that's a different story.
    This makes me think about eventcounts; I have plenty of experience with
    those. God I am getting older. Actually, I am wondering if you happen to
    be familiar with the good ol' two lock queue? I first saw it decades ago:

    https://www.cs.rochester.edu/~scott/papers/1996_PODC_queues.pdf

    A classic! The queues in that paper are well known in lock-free
    circles... Beware... There are subtle memory lifetime issues that can
    occur in the lock-free version. Basically, the same horror show that can
    occur in a lock-free stack. Its not just ABA, its making sure that the
    memory is valid for a certain operation. Iirc, Windows does something
    funky with SEH to get this to work in their SList API.

    ;^)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From HorseyWorsey@the_stables.com@21:1/5 to Chris M. Thomasson on Thu Sep 30 09:35:29 2021
    On Wed, 29 Sep 2021 12:05:24 -0700
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
    On 9/28/2021 7:32 PM, Branimir Maksimovic wrote:
    On 2021-09-28, David Brown <david.brown@hesbynett.no> wrote:
    On 28/09/2021 12:06, Bonita Montero wrote:
    Am 28.09.2021 um 09:05 schrieb Chris M. Thomasson:
    On 9/27/2021 11:34 PM, Bonita Montero wrote:

    If the system hasn't any resources to satisfy a simple WaitForSingle... >>>>>> spinning is quite o.k..


    spinning indeed. However, you have no backoff. You are spinning full >>>>> speed!
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );
    Oh shit. When shit hits the fan, so does this! Try to not bleed the
    system when its in dire straights?

    That doesnt't matter under such conditions.
    Am I talking to a complete moron here ?

    Chris, why do you keep trying to communicate with Bonita? She is
    clearly so convinced of her own superiority to everyone else that it is
    pointless. She does not post code for people to check, she posts it
    because she thinks she is showing off and impressing people. This kind
    of code is difficult to get right, and any capable developer is going to >>> want to discuss it with people to check the details. Since Bonita
    responds with nothing but insults and arrogance, I think it is safe to
    assume her code is flawed and leave her with it.
    She is clever, but newb. Forgive her for that.


    She is clever.

    Clever in a small area. She seems to have limited knowledge of development
    and OS methodologies that arn't commonly used in Windows however.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Thu Sep 30 12:39:29 2021
    That's a bit vague. One can create highly efficient bidirectional communication between two threads using two wait-free single-producer/single-consumer queues without using any atomic RMW's,
    just atomic loads, stores, and some some cleverly placed membars.

    When you use wait-free or lock-free algorithms and there's no data
    you have to poll. That makes wait-free and lock-free algorithms
    out of the question.
    The only lock-free algorihm which ware practicable are lock-free
    stacks. You can use them for pooling objects or to give back items
    to a thread which has allocated the items so that ther's no need
    for a common lock - all modern memory-allocators give back blocks
    freed bei foreign threads to the thread to whose pool the blocks
    belongs.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Chris M. Thomasson on Thu Sep 30 13:00:53 2021
    On 9/29/2021 12:09 PM, Chris M. Thomasson wrote:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might
    be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Have you posted the whole dual_monitor code? If you did, I missed it.
    Sorry.


    In the mean time, I am working on another fractal set to music. Like
    these I did last year:

    https://youtu.be/DSiWvF5QOiI

    https://youtu.be/QFPSYsYUKBA

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Thu Sep 30 13:20:27 2021
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional
    communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic RMW's,
    just atomic loads, stores, and some some cleverly placed membars.

    When you use wait-free or lock-free algorithms and there's no data
    you have to poll.

    Why?

    [...]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Fri Oct 1 03:32:01 2021
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional
    communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic
    RMW's, just atomic loads, stores, and some some cleverly placed membars.

    When you use wait-free or lock-free algorithms and there's no data
    you have to poll.

    Why?

    Because you don't have to wait in the kernel.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From RadicalRabbit@theburrow.co.uk@21:1/5 to Chris M. Thomasson on Fri Oct 1 09:17:08 2021
    On Thu, 30 Sep 2021 13:00:53 -0700
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
    On 9/29/2021 12:09 PM, Chris M. Thomasson wrote:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might
    be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Have you posted the whole dual_monitor code? If you did, I missed it.
    Sorry.


    In the mean time, I am working on another fractal set to music. Like
    these I did last year:

    https://youtu.be/DSiWvF5QOiI

    https://youtu.be/QFPSYsYUKBA

    Very impressive. Could use maybe a few more colours though.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?B?w5bDtiBUaWli?=@21:1/5 to Bonita Montero on Fri Oct 1 04:43:41 2021
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional
    communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic
    RMW's, just atomic loads, stores, and some some cleverly placed membars. >>
    When you use wait-free or lock-free algorithms and there's no data
    you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Fri Oct 1 13:07:11 2021
    On 2021-09-30, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 9/29/2021 12:09 PM, Chris M. Thomasson wrote:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might
    be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Have you posted the whole dual_monitor code? If you did, I missed it.
    Sorry.


    In the mean time, I am working on another fractal set to music. Like
    these I did last year:

    https://youtu.be/DSiWvF5QOiI

    https://youtu.be/QFPSYsYUKBA
    An error occurred. Please try again later. (Playback ID: pHR4vgIqqp13ECHz) Learn More

    --

    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Bonita Montero on Fri Oct 1 13:10:45 2021
    On 2021-10-01, Bonita Montero <Bonita.Montero@gmail.com> wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional
    communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic
    RMW's, just atomic loads, stores, and some some cleverly placed membars. >>>>>
    When you use wait-free or lock-free algorithms and there's no data
    you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it
    spins. Lock-free and wait-free datastructures are idiocracy except
    from lock-free stacks.
    Poof. you spin me around like a record? :P

    --

    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Fri Oct 1 14:59:08 2021
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional
    communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic
    RMW's, just atomic loads, stores, and some some cleverly placed membars. >>>>
    When you use wait-free or lock-free algorithms and there's no data
    you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it
    spins. Lock-free and wait-free datastructures are idiocracy except
    from lock-free stacks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Bonita Montero on Fri Oct 1 13:08:38 2021
    On 2021-10-01, Bonita Montero <Bonita.Montero@gmail.com> wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional
    communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic
    RMW's, just atomic loads, stores, and some some cleverly placed membars. >>>
    When you use wait-free or lock-free algorithms and there's no data
    you have to poll.

    Why?

    Because you don't have to wait in the kernel.

    If you don't spin it is not lock :P
    problem is that only way you don't synchronize
    is when things are *independent* from each other :P

    --

    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Fri Oct 1 13:08:34 2021
    On 10/1/2021 6:07 AM, Branimir Maksimovic wrote:
    On 2021-09-30, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 9/29/2021 12:09 PM, Chris M. Thomasson wrote:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might >>>> be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Have you posted the whole dual_monitor code? If you did, I missed it.
    Sorry.


    In the mean time, I am working on another fractal set to music. Like
    these I did last year:

    https://youtu.be/DSiWvF5QOiI

    https://youtu.be/QFPSYsYUKBA
    An error occurred. Please try again later. (Playback ID: pHR4vgIqqp13ECHz) Learn More


    That's odd. The links I posted work for me. Just checked them. Humm...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Oct 1 13:04:20 2021
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional
    communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic
    RMW's, just atomic loads, stores, and some some cleverly placed
    membars.

    When you use wait-free or lock-free algorithms and there's no data
    you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it
    spins.

    Huh? Ever heard of a futex, or an eventcount? Take a lock-free dynamic
    stack into account. When its empty we can use, say, a futex to wait on
    it. This would be the slow-path. A fast-path is when the stack is not
    empty. There is a big difference between a fast and a slow path. The
    former is lock-free, the latter might have to wait.

    This even works for wait-free structures. In this case, the fast-path
    would be wait-free.


    Lock-free and wait-free datastructures are idiocracy except
    from lock-free stacks.

    Sure. Whatever you say Bonita. Cough.... Cough... ;^)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to RadicalRabbit@theburrow.co.uk on Fri Oct 1 13:11:21 2021
    On 10/1/2021 2:17 AM, RadicalRabbit@theburrow.co.uk wrote:
    On Thu, 30 Sep 2021 13:00:53 -0700
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
    On 9/29/2021 12:09 PM, Chris M. Thomasson wrote:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might >>>> be thrown. These states are all true or false so I combined them to a
    four bit pattern wich I used as an index to a table which stores the
    strings of the out_of_range exception to be trown or a nullptr if the
    state isn't associated with an out of range condition. This helps me
    to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the
    code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Have you posted the whole dual_monitor code? If you did, I missed it.
    Sorry.


    In the mean time, I am working on another fractal set to music. Like
    these I did last year:

    https://youtu.be/DSiWvF5QOiI

    https://youtu.be/QFPSYsYUKBA

    Very impressive.

    Thank you very much for the kind comment! :^)


    Could use maybe a few more colours though.

    Yeah, they could. Humm... I am working on another animation using a more
    robust coloring algorithm for the field lines. Here is an example:

    https://fractalforums.org/gallery/1612-300921002353.png

    The coloring for that one is more dynamic. Also, I am thinking about
    cycling the colors during animation.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Fri Oct 1 20:54:09 2021
    On 2021-10-01, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 6:07 AM, Branimir Maksimovic wrote:
    On 2021-09-30, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 9/29/2021 12:09 PM, Chris M. Thomasson wrote:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might >>>>> be thrown. These states are all true or false so I combined them to a >>>>> four bit pattern wich I used as an index to a table which stores the >>>>> strings of the out_of_range exception to be trown or a nullptr if the >>>>> state isn't associated with an out of range condition. This helps me >>>>> to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the >>>>> code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Have you posted the whole dual_monitor code? If you did, I missed it.
    Sorry.


    In the mean time, I am working on another fractal set to music. Like
    these I did last year:

    https://youtu.be/DSiWvF5QOiI

    https://youtu.be/QFPSYsYUKBA
    An error occurred. Please try again later. (Playback ID: pHR4vgIqqp13ECHz) >> Learn More


    That's odd. The links I posted work for me. Just checked them. Humm...
    Safari, iCloud private relay.... ipv6

    --

    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Oct 1 13:20:10 2021
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional
    communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic
    RMW's, just atomic loads, stores, and some some cleverly placed
    membars.

    When you use wait-free or lock-free algorithms and there's no data
    you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it
    spins. Lock-free and wait-free datastructures are idiocracy except
    from lock-free stacks.

    So a lock-free stack is okay with you, but not a lock-free queue? Why?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Fri Oct 1 20:53:09 2021
    On 2021-10-01, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional >>>>>>> communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic RMW's, >>>>>>> just atomic loads, stores, and some some cleverly placed membars. >>>>>>
    When you use wait-free or lock-free algorithms and there's no data you >>>>>> have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it spins.

    Huh? Ever heard of a futex, or an eventcount? Take a lock-free dynamic stack into account. When its empty we can use, say, a futex to wait on it. This would be the slow-path. A fast-path is when the stack is not empty. There is a big difference between a fast and a slow path. The former is lock-free, the latter might have to wait.

    This even works for wait-free structures. In this case, the fast-path would be wait-free.

    Watch out that "wait free" isn't just spining with more cpomplex algorithm doing nothing usefull :P
    here is mine mutex:
    format elf64

    FUTEX_WAIT equ 0
    FUTEX_WAKE equ 1
    FUTEX_PRIVATE_FLAG equ 128

    public futex_acquire
    public futex_release

    futex_acquire:
    push rbx
    push r15
    ; push r10
    mov r15,rdi
    .L0:
    mov ebx,1
    xor eax,eax
    lock cmpxchg [r15],ebx
    test eax,eax
    jz .L1
    mov eax, 202
    mov rdi, r15
    mov rsi, FUTEX_WAIT or FUTEX_PRIVATE_FLAG
    mov edx, 1
    xor r10,r10
    syscall
    jmp .L0
    .L1:; pop r10
    pop r15
    pop rbx
    ret

    futex_release:
    lock and dword[rdi],0
    mov eax,202
    ; mov rdi, sema
    mov rsi, FUTEX_WAKE or FUTEX_PRIVATE_FLAG
    mov edx,1
    syscall
    ret


    Lock-free and wait-free datastructures are idiocracy except from lock-free >> stacks.

    Sure. Whatever you say Bonita. Cough.... Cough... ;^)
    Heh, rsyncing something, looking bloat and have no patience :p


    --

    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to HorseyWorsey@the_stables.com on Fri Oct 1 13:19:29 2021
    On 9/30/2021 2:35 AM, HorseyWorsey@the_stables.com wrote:
    On Wed, 29 Sep 2021 12:05:24 -0700
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
    On 9/28/2021 7:32 PM, Branimir Maksimovic wrote:
    On 2021-09-28, David Brown <david.brown@hesbynett.no> wrote:
    On 28/09/2021 12:06, Bonita Montero wrote:
    Am 28.09.2021 um 09:05 schrieb Chris M. Thomasson:
    On 9/27/2021 11:34 PM, Bonita Montero wrote:

    If the system hasn't any resources to satisfy a simple WaitForSingle... >>>>>>> spinning is quite o.k..


    spinning indeed. However, you have no backoff. You are spinning full >>>>>> speed!
    while( !SetEvent( (HANDLE)m_xhEvtVisit ) );
    Oh shit. When shit hits the fan, so does this! Try to not bleed the >>>>>> system when its in dire straights?

    That doesnt't matter under such conditions.
    Am I talking to a complete moron here ?

    Chris, why do you keep trying to communicate with Bonita? She is
    clearly so convinced of her own superiority to everyone else that it is >>>> pointless. She does not post code for people to check, she posts it
    because she thinks she is showing off and impressing people. This kind >>>> of code is difficult to get right, and any capable developer is going to >>>> want to discuss it with people to check the details. Since Bonita
    responds with nothing but insults and arrogance, I think it is safe to >>>> assume her code is flawed and leave her with it.
    She is clever, but newb. Forgive her for that.


    She is clever.

    Clever in a small area. She seems to have limited knowledge of development and OS methodologies that arn't commonly used in Windows however.


    She seems to make absolute statements based on her rather narrow views.
    Iirc, she even said something akin to a mutex implementation must use compare-and-swap. I showed her how to do one using only exchange.
    Recently, in this thread she said a lock-free structure, say a lock-free
    stack, has to use spin-polling to wait for an empty state to become,
    non-empty. Well, she is wrong, yet again.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Fri Oct 1 14:24:07 2021
    On 10/1/2021 1:53 PM, Branimir Maksimovic wrote:
    On 2021-10-01, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional >>>>>>>> communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic RMW's, >>>>>>>> just atomic loads, stores, and some some cleverly placed membars. >>>>>>>
    When you use wait-free or lock-free algorithms and there's no data you >>>>>>> have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it spins. >>
    Huh? Ever heard of a futex, or an eventcount? Take a lock-free dynamic stack >> into account. When its empty we can use, say, a futex to wait on it. This
    would be the slow-path. A fast-path is when the stack is not empty. There is >> a big difference between a fast and a slow path. The former is lock-free, the
    latter might have to wait.

    This even works for wait-free structures. In this case, the fast-path would >> be wait-free.

    Watch out that "wait free" isn't just spining with more cpomplex algorithm doing nothing usefull :P

    True! Imvvvho, wait-free should be loopless. Now, I always got nervous
    over trying to implement wait-free with LL/SC, an optimistic atomic
    primitive. I prefer to implement them using pessimistic atomic ops like
    an atomic exchange or fetch-and-add. However, then again atomic exchange
    can be implemented by LL/SC, or CAS. This is not Kosher in my mind.
    Quite fond of the pessimistic x86 XADD or XCHG atomic OPS when it comes
    to wait-free because there is no looping involved. Actually, CAS in x86
    can be used for a state machine without looping because it always
    returns a result. If CAS on x86 fails we have the reason why. This is
    different than LL/SC that can spuriously fail.



    here is mine mutex:
    format elf64

    FUTEX_WAIT equ 0
    FUTEX_WAKE equ 1
    FUTEX_PRIVATE_FLAG equ 128

    public futex_acquire
    public futex_release

    futex_acquire:
    push rbx
    push r15
    ; push r10
    mov r15,rdi
    .L0:
    mov ebx,1
    xor eax,eax
    lock cmpxchg [r15],ebx
    test eax,eax
    jz .L1
    mov eax, 202
    mov rdi, r15
    mov rsi, FUTEX_WAIT or FUTEX_PRIVATE_FLAG
    mov edx, 1
    xor r10,r10
    syscall
    jmp .L0
    .L1:; pop r10
    pop r15
    pop rbx
    ret

    futex_release:
    lock and dword[rdi],0
    mov eax,202
    ; mov rdi, sema
    mov rsi, FUTEX_WAKE or FUTEX_PRIVATE_FLAG
    mov edx,1
    syscall
    ret

    Need to look at it, should work. Fwiw, here is an example using a futex
    on windows. Yes it actually has one, lol! Btw, this is using XCHG only. ______________________________________
    #include <iostream>
    #include <thread>
    #include <functional>

    #define WIN32_LEAN_AND_MEAN
    #include <Windows.h>


    #define CT_L2_ALIGNMENT 128
    #define CT_THREADS 32
    #define CT_ITERS 6666666


    struct ct_futex_mutex
    {
    ULONG alignas(CT_L2_ALIGNMENT) m_state;

    ct_futex_mutex() : m_state(0)
    {

    }

    void lock()
    {
    if (InterlockedExchange(&m_state, 1))
    {
    while (InterlockedExchange(&m_state, 2))
    {
    ULONG cmp = 2;
    WaitOnAddress(&m_state, &cmp, sizeof(ULONG), INFINITE);
    }
    }
    }

    void unlock()
    {
    if (InterlockedExchange(&m_state, 0) == 2)
    {
    WakeByAddressSingle(&m_state);
    }
    }
    };


    struct ct_shared
    {
    ct_futex_mutex m_mtx;
    unsigned long m_count;

    ct_shared() : m_count(0) {}

    ~ct_shared()
    {
    if (m_count != 0)
    {
    std::cout << "counter is totally fubar!\n";
    }
    }
    };


    void ct_thread(ct_shared& shared)
    {
    for (unsigned long i = 0; i < CT_ITERS; ++i)
    {
    shared.m_mtx.lock();
    ++shared.m_count;
    shared.m_mtx.unlock();

    shared.m_mtx.lock();
    --shared.m_count;
    shared.m_mtx.unlock();
    }
    }


    int main()
    {
    std::thread threads[CT_THREADS];

    std::cout << "Starting up...\n";

    {
    ct_shared shared;

    for (unsigned long i = 0; i < CT_THREADS; ++i)
    {
    threads[i] = std::thread(ct_thread, std::ref(shared));
    }

    std::cout << "Running...\n";

    for (unsigned long i = 0; i < CT_THREADS; ++i)
    {
    threads[i].join();
    }
    }

    std::cout << "Completed!\n";

    return 0;
    }
    ______________________________________


    ;^)



    Lock-free and wait-free datastructures are idiocracy except from lock-free >>> stacks.

    Sure. Whatever you say Bonita. Cough.... Cough... ;^)
    Heh, rsyncing something, looking bloat and have no patience :p

    ;^)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Fri Oct 1 22:13:43 2021
    On 2021-10-01, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 1:53 PM, Branimir Maksimovic wrote:
    On 2021-10-01, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional >>>>>>>>> communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic RMW's,
    just atomic loads, stores, and some some cleverly placed membars. >>>>>>>>
    When you use wait-free or lock-free algorithms and there's no data you >>>>>>>> have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it spins. >>>
    Huh? Ever heard of a futex, or an eventcount? Take a lock-free dynamic stack
    into account. When its empty we can use, say, a futex to wait on it. This >>> would be the slow-path. A fast-path is when the stack is not empty. There is
    a big difference between a fast and a slow path. The former is lock-free, the
    latter might have to wait.

    This even works for wait-free structures. In this case, the fast-path would >>> be wait-free.

    Watch out that "wait free" isn't just spining with more cpomplex algorithm >> doing nothing usefull :P

    True! Imvvvho, wait-free should be loopless. Now, I always got nervous
    over trying to implement wait-free with LL/SC, an optimistic atomic primitive. I prefer to implement them using pessimistic atomic ops like
    an atomic exchange or fetch-and-add. However, then again atomic exchange
    can be implemented by LL/SC, or CAS. This is not Kosher in my mind.
    Quite fond of the pessimistic x86 XADD or XCHG atomic OPS when it comes
    to wait-free because there is no looping involved. Actually, CAS in x86
    can be used for a state machine without looping because it always
    returns a result. If CAS on x86 fails we have the reason why. This is different than LL/SC that can spuriously fail.



    here is mine mutex:
    format elf64

    FUTEX_WAIT equ 0
    FUTEX_WAKE equ 1
    FUTEX_PRIVATE_FLAG equ 128

    public futex_acquire
    public futex_release

    futex_acquire:
    push rbx
    push r15
    ; push r10
    mov r15,rdi
    .L0:
    mov ebx,1
    xor eax,eax
    lock cmpxchg [r15],ebx
    test eax,eax
    jz .L1
    mov eax, 202
    mov rdi, r15
    mov rsi, FUTEX_WAIT or FUTEX_PRIVATE_FLAG
    mov edx, 1
    xor r10,r10
    syscall
    jmp .L0
    .L1:; pop r10
    pop r15
    pop rbx
    ret

    futex_release:
    lock and dword[rdi],0
    mov eax,202
    ; mov rdi, sema
    mov rsi, FUTEX_WAKE or FUTEX_PRIVATE_FLAG
    mov edx,1
    syscall
    ret

    Need to look at it, should work. Fwiw, here is an example using a futex
    on windows. Yes it actually has one, lol! Btw, this is using XCHG only. ______________________________________
    #include <iostream>
    #include <thread>
    #include <functional>

    #define WIN32_LEAN_AND_MEAN
    #include <Windows.h>


    #define CT_L2_ALIGNMENT 128
    #define CT_THREADS 32
    #define CT_ITERS 6666666


    struct ct_futex_mutex
    {
    ULONG alignas(CT_L2_ALIGNMENT) m_state;

    ct_futex_mutex() : m_state(0)
    {

    }

    void lock()
    {
    if (InterlockedExchange(&m_state, 1))
    {
    while (InterlockedExchange(&m_state, 2))
    {
    ULONG cmp = 2;
    WaitOnAddress(&m_state, &cmp, sizeof(ULONG), INFINITE);
    }
    }
    }

    void unlock()
    {
    if (InterlockedExchange(&m_state, 0) == 2)
    {
    WakeByAddressSingle(&m_state);
    }
    }
    };


    Same thing practically, except linux futex, which is same thing.
    Interrestingly Darwin does not have it and I am really interrested
    how Apple immplements pthread_mutex?

    --

    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Fri Oct 1 17:14:15 2021
    On 10/1/2021 3:13 PM, Branimir Maksimovic wrote:
    On 2021-10-01, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 1:53 PM, Branimir Maksimovic wrote:
    On 2021-10-01, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote: >>>> On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote: >>>>>>> Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional >>>>>>>>>> communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic RMW's,
    just atomic loads, stores, and some some cleverly placed membars. >>>>>>>>>
    When you use wait-free or lock-free algorithms and there's no data you
    have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it spins.

    Huh? Ever heard of a futex, or an eventcount? Take a lock-free dynamic stack
    into account. When its empty we can use, say, a futex to wait on it. This >>>> would be the slow-path. A fast-path is when the stack is not empty. There is
    a big difference between a fast and a slow path. The former is lock-free, the
    latter might have to wait.

    This even works for wait-free structures. In this case, the fast-path would
    be wait-free.

    Watch out that "wait free" isn't just spining with more cpomplex algorithm >>> doing nothing usefull :P

    True! Imvvvho, wait-free should be loopless. Now, I always got nervous
    over trying to implement wait-free with LL/SC, an optimistic atomic
    primitive. I prefer to implement them using pessimistic atomic ops like
    an atomic exchange or fetch-and-add. However, then again atomic exchange
    can be implemented by LL/SC, or CAS. This is not Kosher in my mind.
    Quite fond of the pessimistic x86 XADD or XCHG atomic OPS when it comes
    to wait-free because there is no looping involved. Actually, CAS in x86
    can be used for a state machine without looping because it always
    returns a result. If CAS on x86 fails we have the reason why. This is
    different than LL/SC that can spuriously fail.



    here is mine mutex:
    format elf64

    FUTEX_WAIT equ 0
    FUTEX_WAKE equ 1
    FUTEX_PRIVATE_FLAG equ 128

    public futex_acquire
    public futex_release

    futex_acquire:
    push rbx
    push r15
    ; push r10
    mov r15,rdi
    .L0:
    mov ebx,1
    xor eax,eax
    lock cmpxchg [r15],ebx
    test eax,eax
    jz .L1
    mov eax, 202
    mov rdi, r15
    mov rsi, FUTEX_WAIT or FUTEX_PRIVATE_FLAG
    mov edx, 1
    xor r10,r10
    syscall
    jmp .L0
    .L1:; pop r10
    pop r15
    pop rbx
    ret

    futex_release:
    lock and dword[rdi],0
    mov eax,202
    ; mov rdi, sema
    mov rsi, FUTEX_WAKE or FUTEX_PRIVATE_FLAG
    mov edx,1
    syscall
    ret

    Need to look at it, should work. Fwiw, here is an example using a futex
    on windows. Yes it actually has one, lol! Btw, this is using XCHG only. >> ______________________________________
    #include <iostream>
    #include <thread>
    #include <functional>

    #define WIN32_LEAN_AND_MEAN
    #include <Windows.h>


    #define CT_L2_ALIGNMENT 128
    #define CT_THREADS 32
    #define CT_ITERS 6666666


    struct ct_futex_mutex
    {
    ULONG alignas(CT_L2_ALIGNMENT) m_state;

    ct_futex_mutex() : m_state(0)
    {

    }

    void lock()
    {
    if (InterlockedExchange(&m_state, 1))
    {
    while (InterlockedExchange(&m_state, 2))
    {
    ULONG cmp = 2;
    WaitOnAddress(&m_state, &cmp, sizeof(ULONG), INFINITE);
    }
    }
    }

    void unlock()
    {
    if (InterlockedExchange(&m_state, 0) == 2)
    {
    WakeByAddressSingle(&m_state);
    }
    }
    };


    Same thing practically, except linux futex, which is same thing. Interrestingly Darwin does not have it and I am really interrested
    how Apple immplements pthread_mutex?


    Ohhhh... Good question. I am not sure about Darwin. Actually, there is a
    way to implement the mutex I showed you using binary semaphores for the
    slow path. Iirc, it went like this, with the futex part commented out,
    and the initialization of the binary sema to zero, auto-reset event on
    windoze, also out:
    ____________________________
    struct ct_futex_mutex
    {
    ULONG alignas(CT_L2_ALIGNMENT) m_state;

    ct_futex_mutex() : m_state(0)
    {

    }

    void lock()
    {
    if (InterlockedExchange(&m_state, 1))
    {
    while (InterlockedExchange(&m_state, 2))
    {
    //ULONG cmp = 2;
    //WaitOnAddress(&m_state, &cmp, sizeof(ULONG), INFINITE);

    WaitForSingleObject(m_event, INFINITE);
    }
    }
    }

    void unlock()
    {
    if (InterlockedExchange(&m_state, 0) == 2)
    {
    //WakeByAddressSingle(&m_state);

    SetEvent(m_event);
    }
    }
    };
    ____________________________

    That works as well. Humm...

    https://github.com/apple/darwin-libpthread/blob/main/man/pthread_mutex_lock.3

    https://github.com/apple/darwin-libpthread/blob/main/src/pthread_mutex.c

    Need to example this! There is another way to create a nice FIFO mutex
    using a fast semaphore. Iirc, it was called a benaphore:

    https://www.haiku-os.org/legacy-docs/benewsletter/Issue1-26.html#Engineering1-26

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Chris M. Thomasson on Fri Oct 1 17:16:22 2021
    On 10/1/2021 5:14 PM, Chris M. Thomasson wrote:
    On 10/1/2021 3:13 PM, Branimir Maksimovic wrote:
    On 2021-10-01, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote: [...]


    There is another way to create a nice FIFO mutex
    using a fast semaphore. Iirc, it was called a benaphore:

    https://www.haiku-os.org/legacy-docs/benewsletter/Issue1-26.html#Engineering1-26


    Basically, its adding the ability to avoid the kernel using a fast-path
    on the semaphore logic. Also, its wait-free on the fast-path because it
    can be implemented using XADD.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to David Brown on Fri Oct 1 18:00:41 2021
    On 9/30/2021 12:10 AM, David Brown wrote:
    On 30/09/2021 03:33, Bonita Montero wrote:
    Am 29.09.2021 um 21:05 schrieb Chris M. Thomasson:
    On 9/29/2021 3:41 AM, Bonita Montero wrote:
    Am 28.09.2021 um 23:42 schrieb Chris M. Thomasson:

    Yeah. Damn. She does not seem to know a whole lot about memory
    barriers,

    I use them a lot and correctly.


    A wait on a semaphore does not need release semantics. ...

    It needs because I could have modiefied data before releasing the
    lock I'm waiting for just at the same time.


    If you release a lock, you need release semantics. If you acquire a
    lock, you need acquire semantics.

    There is a lot of fiddly stuff in getting memory barriers and
    synchronisation right - and a lot of /really/ tough stuff in getting it
    right and optimally efficient on big processors. But "acquire" and
    "release" semantics are helpfully named!


    They are named nicely. Back on the SPARC acquire is:

    MEMBAR #LoadStore | #LoadLoad

    Release is:

    MEMBAR #LoadStore | #StoreStore

    Ahhh, then we have hardcore: #StoreLoad. SMR required this on the SPARC.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Chris M. Thomasson on Fri Oct 1 18:01:51 2021
    On 10/1/2021 6:00 PM, Chris M. Thomasson wrote:
    On 9/30/2021 12:10 AM, David Brown wrote:
    On 30/09/2021 03:33, Bonita Montero wrote:
    Am 29.09.2021 um 21:05 schrieb Chris M. Thomasson:
    On 9/29/2021 3:41 AM, Bonita Montero wrote:
    Am 28.09.2021 um 23:42 schrieb Chris M. Thomasson:

    Yeah. Damn. She does not seem to know a whole lot about memory
    barriers,

    I use them a lot and correctly.


    A wait on a semaphore does not need release semantics. ...

    It needs because I could have modiefied data before releasing the
    lock I'm waiting for just at the same time.


    If you release a lock, you need release semantics.  If you acquire a
    lock, you need acquire semantics.

    There is a lot of fiddly stuff in getting memory barriers and
    synchronisation right - and a lot of /really/ tough stuff in getting it
    right and optimally efficient on big processors.  But "acquire" and
    "release" semantics are helpfully named!


    They are named nicely. Back on the SPARC acquire is:

    MEMBAR #LoadStore | #LoadLoad

    Release is:

    MEMBAR #LoadStore | #StoreStore

    Ahhh, then we have hardcore: #StoreLoad. SMR required this on the SPARC.

    Heck, it even required it on the x86! LOCK'ed atomic or MFENCE.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Sat Oct 2 01:44:40 2021
    On 2021-10-02, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    FUTEX_WAKE equ 1
    Same thing practically, except linux futex, which is same thing.
    Interrestingly Darwin does not have it and I am really interrested
    how Apple immplements pthread_mutex?


    Ohhhh... Good question. I am not sure about Darwin. Actually, there is a
    way to implement the mutex I showed you using binary semaphores for the
    slow path. Iirc, it went like this, with the futex part commented out,
    and the initialization of the binary sema to zero, auto-reset event on windoze, also out:
    Problem is that Apple act like student newbs. They don't care about
    API stability and code in general. Puring empty to void, you have
    to waste time a lot if programming for macOS...

    ____________________________
    struct ct_futex_mutex
    {
    ULONG alignas(CT_L2_ALIGNMENT) m_state;

    ct_futex_mutex() : m_state(0)
    {

    }

    void lock()
    {
    if (InterlockedExchange(&m_state, 1))
    {
    while (InterlockedExchange(&m_state, 2))
    {
    //ULONG cmp = 2;
    //WaitOnAddress(&m_state, &cmp, sizeof(ULONG), INFINITE);

    WaitForSingleObject(m_event, INFINITE);
    }
    }
    }

    void unlock()
    {
    if (InterlockedExchange(&m_state, 0) == 2)
    {
    //WakeByAddressSingle(&m_state);

    SetEvent(m_event);
    }
    }
    };
    ____________________________

    That works as well. Humm...
    yeah...

    https://github.com/apple/darwin-libpthread/blob/main/man/pthread_mutex_lock.3

    https://github.com/apple/darwin-libpthread/blob/main/src/pthread_mutex.c

    Need to example this! There is another way to create a nice FIFO mutex
    using a fast semaphore. Iirc, it was called a benaphore:

    https://www.haiku-os.org/legacy-docs/benewsletter/Issue1-26.html#Engineering1-26
    I look...

    --

    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Sat Oct 2 02:14:46 2021
    On 2021-10-02, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 3:13 PM, Branimir Maksimovic wrote:
    On 2021-10-01, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 1:53 PM, Branimir Maksimovic wrote:
    On 2021-10-01, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote: >>>>> On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote: >>>>>>>> Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional >>>>>>>>>>> communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic >>>>>>>>>>> RMW's, just atomic loads, stores, and some some cleverly placed >>>>>>>>>>> membars.

    When you use wait-free or lock-free algorithms and there's no data >>>>>>>>>> you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it >>>>>> spins.

    Huh? Ever heard of a futex, or an eventcount? Take a lock-free dynamic >>>>> stack into account. When its empty we can use, say, a futex to wait on >>>>> it. This would be the slow-path. A fast-path is when the stack is not >>>>> empty. There is a big difference between a fast and a slow path. The >>>>> former is lock-free, the latter might have to wait.

    This even works for wait-free structures. In this case, the fast-path >>>>> would be wait-free.

    Watch out that "wait free" isn't just spining with more cpomplex algorithm >>>> doing nothing usefull :P

    True! Imvvvho, wait-free should be loopless. Now, I always got nervous over >>> trying to implement wait-free with LL/SC, an optimistic atomic primitive. I >>> prefer to implement them using pessimistic atomic ops like an atomic
    exchange or fetch-and-add. However, then again atomic exchange can be
    implemented by LL/SC, or CAS. This is not Kosher in my mind. Quite fond of >>> the pessimistic x86 XADD or XCHG atomic OPS when it comes to wait-free
    because there is no looping involved. Actually, CAS in x86 can be used for >>> a state machine without looping because it always returns a result. If CAS >>> on x86 fails we have the reason why. This is different than LL/SC that can >>> spuriously fail.



    here is mine mutex: format elf64

    FUTEX_WAIT equ 0 FUTEX_WAKE equ 1
    FUTEX_PRIVATE_FLAG equ 128

    public futex_acquire public futex_release

    futex_acquire: push rbx push r15 ; push r10 mov r15,rdi .L0: mov ebx,1 xor >>>> eax,eax lock cmpxchg [r15],ebx test eax,eax jz .L1 mov eax, 202 mov rdi, >>>> r15 mov rsi, FUTEX_WAIT or FUTEX_PRIVATE_FLAG mov edx, 1 xor r10,r10
    syscall jmp .L0 .L1:; pop r10 pop r15 pop rbx ret

    futex_release: lock and dword[rdi],0 mov eax,202 ; mov rdi, sema >>>> mov rsi, FUTEX_WAKE or FUTEX_PRIVATE_FLAG mov edx,1 syscall ret

    Need to look at it, should work. Fwiw, here is an example using a futex on >>> windows. Yes it actually has one, lol! Btw, this is using XCHG only.
    ______________________________________ #include <iostream> #include
    <thread> #include <functional>

    #define WIN32_LEAN_AND_MEAN #include <Windows.h>


    #define CT_L2_ALIGNMENT 128 #define CT_THREADS 32 #define CT_ITERS 6666666 >>>

    struct ct_futex_mutex { ULONG alignas(CT_L2_ALIGNMENT) m_state;

    ct_futex_mutex() : m_state(0) {

    }

    void lock() { if (InterlockedExchange(&m_state, 1)) { while
    (InterlockedExchange(&m_state, 2)) { ULONG cmp = 2;
    WaitOnAddress(&m_state, &cmp, sizeof(ULONG), INFINITE); } } }

    void unlock() { if (InterlockedExchange(&m_state, 0) == 2) {
    WakeByAddressSingle(&m_state); } } };


    Same thing practically, except linux futex, which is same thing.
    Interrestingly Darwin does not have it and I am really interrested how Apple >> immplements pthread_mutex?


    Ohhhh... Good question. I am not sure about Darwin. Actually, there is a way to implement the mutex I showed you using binary semaphores for the slow path. Iirc, it went like this, with the futex part commented out, and the initialization of the binary sema to zero, auto-reset event on windoze, also out: ____________________________ struct ct_futex_mutex { ULONG alignas(CT_L2_ALIGNMENT) m_state;

    ct_futex_mutex() : m_state(0) {

    }

    void lock() { if (InterlockedExchange(&m_state, 1)) { while
    (InterlockedExchange(&m_state, 2)) { //ULONG cmp = 2;
    //WaitOnAddress(&m_state, &cmp, sizeof(ULONG), INFINITE);

    WaitForSingleObject(m_event, INFINITE); } } }

    void unlock() { if (InterlockedExchange(&m_state, 0) == 2) {
    //WakeByAddressSingle(&m_state);

    SetEvent(m_event); } } }; ____________________________

    That works as well. Humm...

    https://github.com/apple/darwin-libpthread/blob/main/man/pthread_mutex_lock.3

    https://github.com/apple/darwin-libpthread/blob/main/src/pthread_mutex.c

    Need to example this! There is another way to create a nice FIFO mutex using a fast semaphore. Iirc, it was called a benaphore:

    https://www.haiku-os.org/legacy-docs/benewsletter/Issue1-26.html#Engineering1-26
    Here is Apple version:
    #include <locale>
    #include <iostream>
    #include <thread>
    #include <semaphore.h>
    #include <functional>

    #define CT_L2_ALIGNMENT 128
    #define CT_THREADS 32
    #define CT_ITERS 666666
    using ULONG = unsigned long;

    struct ct_futex_mutex
    {
    sem_t sema;
    alignas(CT_L2_ALIGNMENT) ULONG m_state;

    ct_futex_mutex() : m_state(0)
    {
    sem_init(&sema,0,0);
    }

    void lock()
    {
    if (__sync_swap(&m_state, 1))
    {
    while (__sync_swap(&m_state, 2))
    {
    sem_wait(&sema);
    }
    }
    }

    void unlock()
    {
    if (__sync_swap(&m_state, 0) == 2)
    {
    sem_post(&sema);
    }
    }
    };


    struct ct_shared
    {
    ct_futex_mutex m_mtx;
    unsigned long m_count;

    ct_shared() : m_count(0) {}

    ~ct_shared()
    {
    if (m_count != 0)
    {
    std::cout << "counter is totally fubar!\n";
    }
    }
    };


    void ct_thread(ct_shared& shared)
    {
    for (unsigned long i = 0; i < CT_ITERS; ++i)
    {
    shared.m_mtx.lock();
    ++shared.m_count;
    shared.m_mtx.unlock();

    shared.m_mtx.lock();
    --shared.m_count;
    shared.m_mtx.unlock();
    }
    }


    int main()
    {
    std::locale mylocale("");
    std::cout.imbue(mylocale); // use locale number formatting style
    std::thread *threads = new std::thread[CT_THREADS];

    std::cout << "Starting up...\n";

    {
    ct_shared shared;

    for (unsigned long i = 0; i < CT_THREADS; ++i)
    {
    threads[i] = std::thread(ct_thread, std::ref(shared));
    }

    std::cout << "Running...\n";

    for (unsigned long i = 0; i < CT_THREADS; ++i)
    {
    threads[i].join();
    }
    }

    std::cout << "Completed!\n";

    return 0;
    }

    /**
    ;^)



    Lock-free and wait-free datastructures are idiocracy except from lock-free >>> stacks.

    Sure. Whatever you say Bonita. Cough.... Cough... ;^)
    Heh, rsyncing something, looking bloat and have no patience :p

    ;^)
    */



    --

    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Fri Oct 1 19:33:53 2021
    On 10/1/2021 7:14 PM, Branimir Maksimovic wrote:
    On 2021-10-02, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 3:13 PM, Branimir Maksimovic wrote:
    On 2021-10-01, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote: >>>> On 10/1/2021 1:53 PM, Branimir Maksimovic wrote:
    On 2021-10-01, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote: >>>>>> On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote: >>>>>>>>> Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional >>>>>>>>>>>> communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic >>>>>>>>>>>> RMW's, just atomic loads, stores, and some some cleverly placed >>>>>>>>>>>> membars.

    When you use wait-free or lock-free algorithms and there's no data >>>>>>>>>>> you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it >>>>>>> spins.

    Huh? Ever heard of a futex, or an eventcount? Take a lock-free dynamic >>>>>> stack into account. When its empty we can use, say, a futex to wait on >>>>>> it. This would be the slow-path. A fast-path is when the stack is not >>>>>> empty. There is a big difference between a fast and a slow path. The >>>>>> former is lock-free, the latter might have to wait.

    This even works for wait-free structures. In this case, the fast-path >>>>>> would be wait-free.

    Watch out that "wait free" isn't just spining with more cpomplex algorithm
    doing nothing usefull :P

    True! Imvvvho, wait-free should be loopless. Now, I always got nervous over
    trying to implement wait-free with LL/SC, an optimistic atomic primitive. I
    prefer to implement them using pessimistic atomic ops like an atomic
    exchange or fetch-and-add. However, then again atomic exchange can be
    implemented by LL/SC, or CAS. This is not Kosher in my mind. Quite fond of
    the pessimistic x86 XADD or XCHG atomic OPS when it comes to wait-free >>>> because there is no looping involved. Actually, CAS in x86 can be used for >>>> a state machine without looping because it always returns a result. If CAS >>>> on x86 fails we have the reason why. This is different than LL/SC that can >>>> spuriously fail.



    here is mine mutex: format elf64

    FUTEX_WAIT equ 0 FUTEX_WAKE equ 1
    FUTEX_PRIVATE_FLAG equ 128

    public futex_acquire public futex_release

    futex_acquire: push rbx push r15 ; push r10 mov r15,rdi .L0: mov ebx,1 xor
    eax,eax lock cmpxchg [r15],ebx test eax,eax jz .L1 mov eax, 202 mov rdi, >>>>> r15 mov rsi, FUTEX_WAIT or FUTEX_PRIVATE_FLAG mov edx, 1 xor r10,r10 >>>>> syscall jmp .L0 .L1:; pop r10 pop r15 pop rbx ret

    futex_release: lock and dword[rdi],0 mov eax,202 ; mov rdi, sema >>>>> mov rsi, FUTEX_WAKE or FUTEX_PRIVATE_FLAG mov edx,1 syscall ret

    Need to look at it, should work. Fwiw, here is an example using a futex on >>>> windows. Yes it actually has one, lol! Btw, this is using XCHG only.
    ______________________________________ #include <iostream> #include
    <thread> #include <functional>

    #define WIN32_LEAN_AND_MEAN #include <Windows.h>


    #define CT_L2_ALIGNMENT 128 #define CT_THREADS 32 #define CT_ITERS 6666666 >>>>

    struct ct_futex_mutex { ULONG alignas(CT_L2_ALIGNMENT) m_state;

    ct_futex_mutex() : m_state(0) {

    }

    void lock() { if (InterlockedExchange(&m_state, 1)) { while
    (InterlockedExchange(&m_state, 2)) { ULONG cmp = 2;
    WaitOnAddress(&m_state, &cmp, sizeof(ULONG), INFINITE); } } }

    void unlock() { if (InterlockedExchange(&m_state, 0) == 2) {
    WakeByAddressSingle(&m_state); } } };


    Same thing practically, except linux futex, which is same thing.
    Interrestingly Darwin does not have it and I am really interrested how Apple
    immplements pthread_mutex?


    Ohhhh... Good question. I am not sure about Darwin. Actually, there is a way >> to implement the mutex I showed you using binary semaphores for the slow
    path. Iirc, it went like this, with the futex part commented out, and the
    initialization of the binary sema to zero, auto-reset event on windoze, also >> out: ____________________________ struct ct_futex_mutex { ULONG
    alignas(CT_L2_ALIGNMENT) m_state;

    ct_futex_mutex() : m_state(0) {

    }

    void lock() { if (InterlockedExchange(&m_state, 1)) { while
    (InterlockedExchange(&m_state, 2)) { //ULONG cmp = 2;
    //WaitOnAddress(&m_state, &cmp, sizeof(ULONG), INFINITE);

    WaitForSingleObject(m_event, INFINITE); } } }

    void unlock() { if (InterlockedExchange(&m_state, 0) == 2) {
    //WakeByAddressSingle(&m_state);

    SetEvent(m_event); } } }; ____________________________

    That works as well. Humm...

    https://github.com/apple/darwin-libpthread/blob/main/man/pthread_mutex_lock.3

    https://github.com/apple/darwin-libpthread/blob/main/src/pthread_mutex.c

    Need to example this! There is another way to create a nice FIFO mutex using >> a fast semaphore. Iirc, it was called a benaphore:

    https://www.haiku-os.org/legacy-docs/benewsletter/Issue1-26.html#Engineering1-26
    Here is Apple version:
    [...]

    Excellent! That is basically identical to the bin-sema version! For what
    its worth, take reference to a man by the name of Alexander Terekhov!
    And look at the code in pthreads-win32 sources. I used to converse with
    this genius way back on comp.programming.threads. He was a pleasure to
    talk to. Actually, I am SenderX way back here:

    https://groups.google.com/g/comp.programming.threads/c/KepRbFWBJA4/m/pg83oJTzPUIJ

    ;^)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Oct 1 22:12:25 2021
    On 10/1/2021 9:39 PM, Bonita Montero wrote:
    Am 01.10.2021 um 22:04 schrieb Chris M. Thomasson:
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional >>>>>>>> communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic >>>>>>>> RMW's, just atomic loads, stores, and some some cleverly placed >>>>>>>> membars.

    When you use wait-free or lock-free algorithms and there's no data >>>>>>> you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it
    spins.

    Huh? Ever heard of a futex, or an eventcount?

    Lock-free is without any kernel-structures and polling only.
    No futex.

    Lock-free on the fast-path... Ever heard of such a thing? Wow.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 06:40:39 2021
    Am 01.10.2021 um 22:20 schrieb Chris M. Thomasson:
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional >>>>>>> communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic
    RMW's, just atomic loads, stores, and some some cleverly placed
    membars.

    When you use wait-free or lock-free algorithms and there's no data >>>>>> you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it
    spins. Lock-free and wait-free datastructures are idiocracy except
    from lock-free stacks.

    So a lock-free stack is okay with you, but not a lock-free queue? Why?

    Because the use-cases of lock-free stacks are so that the
    lock-free stacks are never polled.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 06:39:44 2021
    Am 01.10.2021 um 22:04 schrieb Chris M. Thomasson:
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional >>>>>>> communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic
    RMW's, just atomic loads, stores, and some some cleverly placed
    membars.

    When you use wait-free or lock-free algorithms and there's no data >>>>>> you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it
    spins.

    Huh? Ever heard of a futex, or an eventcount?

    Lock-free is without any kernel-structures and polling only.
    No futex.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Oct 1 22:14:05 2021
    On 10/1/2021 9:40 PM, Bonita Montero wrote:
    Am 01.10.2021 um 22:20 schrieb Chris M. Thomasson:
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional >>>>>>>> communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic >>>>>>>> RMW's, just atomic loads, stores, and some some cleverly placed >>>>>>>> membars.

    When you use wait-free or lock-free algorithms and there's no data >>>>>>> you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it
    spins. Lock-free and wait-free datastructures are idiocracy except
    from lock-free stacks.

    So a lock-free stack is okay with you, but not a lock-free queue? Why?

    Because the use-cases of lock-free stacks are so that the
    lock-free stacks are never polled.


    Never polled? A slow-path on a lock-free stack can be waited on.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 07:35:35 2021
    Am 02.10.2021 um 07:12 schrieb Chris M. Thomasson:
    On 10/1/2021 9:39 PM, Bonita Montero wrote:
    Am 01.10.2021 um 22:04 schrieb Chris M. Thomasson:
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional >>>>>>>>> communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic >>>>>>>>> RMW's, just atomic loads, stores, and some some cleverly placed >>>>>>>>> membars.

    When you use wait-free or lock-free algorithms and there's no data >>>>>>>> you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it
    spins.

    Huh? Ever heard of a futex, or an eventcount?

    Lock-free is without any kernel-structures and polling only.
    No futex.

    Lock-free on the fast-path... Ever heard of such a thing? Wow.

    There is no slow path with lock-free structures.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 07:36:20 2021
    Am 02.10.2021 um 07:14 schrieb Chris M. Thomasson:
    On 10/1/2021 9:40 PM, Bonita Montero wrote:
    Am 01.10.2021 um 22:20 schrieb Chris M. Thomasson:
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional >>>>>>>>> communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic >>>>>>>>> RMW's, just atomic loads, stores, and some some cleverly placed >>>>>>>>> membars.

    When you use wait-free or lock-free algorithms and there's no data >>>>>>>> you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it
    spins. Lock-free and wait-free datastructures are idiocracy except
    from lock-free stacks.

    So a lock-free stack is okay with you, but not a lock-free queue? Why?

    Because the use-cases of lock-free stacks are so that the
    lock-free stacks are never polled.


    Never polled? A slow-path on a lock-free stack can be waited on.

    Then it isn't lock-free.
    I think I'm talking to a complete moron here.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Oct 1 22:49:29 2021
    On 10/1/2021 10:35 PM, Bonita Montero wrote:
    Am 02.10.2021 um 07:12 schrieb Chris M. Thomasson:
    On 10/1/2021 9:39 PM, Bonita Montero wrote:
    Am 01.10.2021 um 22:04 schrieb Chris M. Thomasson:
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote: >>>>>>> Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional >>>>>>>>>> communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic >>>>>>>>>> RMW's, just atomic loads, stores, and some some cleverly
    placed membars.

    When you use wait-free or lock-free algorithms and there's no data >>>>>>>>> you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it
    spins.

    Huh? Ever heard of a futex, or an eventcount?

    Lock-free is without any kernel-structures and polling only.
    No futex.

    Lock-free on the fast-path... Ever heard of such a thing? Wow.

    There is no slow path with lock-free structures.

    Ummmm... You are just trolling me right? A slow path would be what to do
    when one needs to wait, on say, an empty condition? Humm... Why do you
    troll?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 08:00:39 2021
    Am 02.10.2021 um 07:55 schrieb Chris M. Thomasson:
    On 10/1/2021 10:36 PM, Bonita Montero wrote:
    Am 02.10.2021 um 07:14 schrieb Chris M. Thomasson:
    On 10/1/2021 9:40 PM, Bonita Montero wrote:
    Am 01.10.2021 um 22:20 schrieb Chris M. Thomasson:
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote: >>>>>>>> Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient
    bidirectional
    communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic >>>>>>>>>>> RMW's, just atomic loads, stores, and some some cleverly >>>>>>>>>>> placed membars.

    When you use wait-free or lock-free algorithms and there's no >>>>>>>>>> data
    you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it >>>>>> spins. Lock-free and wait-free datastructures are idiocracy except >>>>>> from lock-free stacks.

    So a lock-free stack is okay with you, but not a lock-free queue? Why? >>>>
    Because the use-cases of lock-free stacks are so that the
    lock-free stacks are never polled.


    Never polled? A slow-path on a lock-free stack can be waited on.

    Then it isn't lock-free.
    I think I'm talking to a complete moron here.


    Fast-path lock/wait-free, slow-path might have to hit the kernel to wait
    on certain conditions. You seem to have never differentiated between the
    two possible paths?

    Lock-free is when there's no kernel-locking involved.
    And a slow-path involves kernel-locking.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Oct 1 23:12:21 2021
    On 10/1/2021 11:00 PM, Bonita Montero wrote:
    Am 02.10.2021 um 07:49 schrieb Chris M. Thomasson:
    On 10/1/2021 10:35 PM, Bonita Montero wrote:
    Am 02.10.2021 um 07:12 schrieb Chris M. Thomasson:
    On 10/1/2021 9:39 PM, Bonita Montero wrote:
    Am 01.10.2021 um 22:04 schrieb Chris M. Thomasson:
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote: >>>>>>>>> Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient
    bidirectional
    communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic >>>>>>>>>>>> RMW's, just atomic loads, stores, and some some cleverly >>>>>>>>>>>> placed membars.

    When you use wait-free or lock-free algorithms and there's no >>>>>>>>>>> data
    you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it >>>>>>> spins.

    Huh? Ever heard of a futex, or an eventcount?

    Lock-free is without any kernel-structures and polling only.
    No futex.

    Lock-free on the fast-path... Ever heard of such a thing? Wow.

    There is no slow path with lock-free structures.

    Ummmm... You are just trolling me right? A slow path would be what to
    do when one needs to wait, on say, an empty condition? Humm... Why do
    you troll?

    Lock-free is when there's no kernel-locking involved.

    A fast-path can be 100% pure lock/wait-free, so yes; indeed. A slow-path
    can involve kernel locking. Are you late to the game?

    And a slow-path involves kernel-locking.

    Yes. So, a lock/wait-free fast-path in user-space can be realized,
    right? Think about it, then think about it again. So can a slow-path.
    The target usage paradigm is to use a lot more fast-paths, than slow
    ones... ;^)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Oct 1 23:08:08 2021
    On 10/1/2021 11:00 PM, Bonita Montero wrote:
    Am 02.10.2021 um 07:55 schrieb Chris M. Thomasson:
    On 10/1/2021 10:36 PM, Bonita Montero wrote:
    Am 02.10.2021 um 07:14 schrieb Chris M. Thomasson:
    On 10/1/2021 9:40 PM, Bonita Montero wrote:
    Am 01.10.2021 um 22:20 schrieb Chris M. Thomasson:
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote: >>>>>>>>> Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient
    bidirectional
    communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic >>>>>>>>>>>> RMW's, just atomic loads, stores, and some some cleverly >>>>>>>>>>>> placed membars.

    When you use wait-free or lock-free algorithms and there's no >>>>>>>>>>> data
    you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it >>>>>>> spins. Lock-free and wait-free datastructures are idiocracy except >>>>>>> from lock-free stacks.

    So a lock-free stack is okay with you, but not a lock-free queue?
    Why?

    Because the use-cases of lock-free stacks are so that the
    lock-free stacks are never polled.


    Never polled? A slow-path on a lock-free stack can be waited on.

    Then it isn't lock-free.
    I think I'm talking to a complete moron here.


    Fast-path lock/wait-free, slow-path might have to hit the kernel to
    wait on certain conditions. You seem to have never differentiated
    between the two possible paths?

    Lock-free is when there's no kernel-locking involved.
    And a slow-path involves kernel-locking.

    One cal use lock-free in user-space! A futex or eventcount can be used
    to help it out. You know, if it must wait on an empty condition, well,
    it can without spinning around. If the queue/stack is empty, we can
    wait! Or not. Up to the programmer.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Oct 1 22:55:01 2021
    On 10/1/2021 10:36 PM, Bonita Montero wrote:
    Am 02.10.2021 um 07:14 schrieb Chris M. Thomasson:
    On 10/1/2021 9:40 PM, Bonita Montero wrote:
    Am 01.10.2021 um 22:20 schrieb Chris M. Thomasson:
    On 10/1/2021 5:59 AM, Bonita Montero wrote:
    Am 01.10.2021 um 13:43 schrieb Öö Tiib:
    On Friday, 1 October 2021 at 04:32:18 UTC+3, Bonita Montero wrote: >>>>>>> Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional >>>>>>>>>> communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic >>>>>>>>>> RMW's, just atomic loads, stores, and some some cleverly
    placed membars.

    When you use wait-free or lock-free algorithms and there's no data >>>>>>>>> you have to poll.

    Why?
    Because you don't have to wait in the kernel.

    What a thread does when its input queue is empty?

    If it hasn't anything other to do than "waiting" for a new entry it
    spins. Lock-free and wait-free datastructures are idiocracy except
    from lock-free stacks.

    So a lock-free stack is okay with you, but not a lock-free queue? Why?

    Because the use-cases of lock-free stacks are so that the
    lock-free stacks are never polled.


    Never polled? A slow-path on a lock-free stack can be waited on.

    Then it isn't lock-free.
    I think I'm talking to a complete moron here.


    Fast-path lock/wait-free, slow-path might have to hit the kernel to wait
    on certain conditions. You seem to have never differentiated between the
    two possible paths?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Oct 1 23:39:14 2021
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:12 schrieb Chris M. Thomasson:

    Lock-free is when there's no kernel-locking involved.

    A fast-path can be 100% pure lock/wait-free, so yes; indeed.
    A slow-path  can involve kernel locking. Are you late to the game?

    And if you have kernel-locking you don't have any lock-free algorithm.

    WRONG! Think of the difference between a fast-path and a slow-path. The programmer can decide what to do.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 08:38:10 2021
    Am 02.10.2021 um 08:12 schrieb Chris M. Thomasson:

    Lock-free is when there's no kernel-locking involved.

    A fast-path can be 100% pure lock/wait-free, so yes; indeed.
    A slow-path can involve kernel locking. Are you late to the game?

    And if you have kernel-locking you don't have any lock-free algorithm.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 08:47:28 2021
    Am 02.10.2021 um 08:41 schrieb Chris M. Thomasson:
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:08 schrieb Chris M. Thomasson:

    One cal use lock-free in user-space! A futex or eventcount can be
    used to help it out. You know, if it must wait on an empty condition,
    well, it can without spinning around. If the queue/stack is empty, we
    can wait! Or not. Up to the programmer.

    If you have a slow path you don't have a lock-free algorithm.

    Why not? The slow-path can be avoided, from time to time. ...

    Lock-free is without locking all the time.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Chris M. Thomasson on Fri Oct 1 23:44:42 2021
    On 10/1/2021 11:41 PM, Chris M. Thomasson wrote:
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:08 schrieb Chris M. Thomasson:

    One cal use lock-free in user-space! A futex or eventcount can be
    used to help it out. You know, if it must wait on an empty condition,
    well, it can without spinning around. If the queue/stack is empty, we
    can wait! Or not. Up to the programmer.

    If you have a slow path you don't have a lock-free algorithm.

    Why not? The slow-path can be avoided, from time to time. Ever heard
    about doing something else, instead of waiting in kernel land? I have
    some older code that can show this. Its the type of thinking were...
    Well, why should I wait when I can do something else. Actually, it works.


    Think of a slow-path as being when a lock is locked; shit need to wait.
    And a fast-path as being able to acquire it without waiting. Well,
    instead of waiting, do something else? It can be coded, so to speak
    using some interesting logic. ;^)

    I am trying to teach you.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Oct 1 23:41:49 2021
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:08 schrieb Chris M. Thomasson:

    One cal use lock-free in user-space! A futex or eventcount can be used
    to help it out. You know, if it must wait on an empty condition, well,
    it can without spinning around. If the queue/stack is empty, we can
    wait! Or not. Up to the programmer.

    If you have a slow path you don't have a lock-free algorithm.

    Why not? The slow-path can be avoided, from time to time. Ever heard
    about doing something else, instead of waiting in kernel land? I have
    some older code that can show this. Its the type of thinking were...
    Well, why should I wait when I can do something else. Actually, it works.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 08:46:58 2021
    Am 02.10.2021 um 08:39 schrieb Chris M. Thomasson:
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:12 schrieb Chris M. Thomasson:

    Lock-free is when there's no kernel-locking involved.

    A fast-path can be 100% pure lock/wait-free, so yes; indeed.
    A slow-path  can involve kernel locking. Are you late to the game?

    And if you have kernel-locking you don't have any lock-free algorithm.

    WRONG! Think of the difference between a fast-path and a slow-path. The programmer can decide what to do.

    No, not wrong. Lock-free is always without waiting in the kernel,
    i.e. no locking.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Oct 1 23:50:40 2021
    On 10/1/2021 11:46 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:39 schrieb Chris M. Thomasson:
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:12 schrieb Chris M. Thomasson:

    Lock-free is when there's no kernel-locking involved.

    A fast-path can be 100% pure lock/wait-free, so yes; indeed.
    A slow-path  can involve kernel locking. Are you late to the game?

    And if you have kernel-locking you don't have any lock-free algorithm.

    WRONG! Think of the difference between a fast-path and a slow-path.
    The programmer can decide what to do.

    No, not wrong. Lock-free is always without waiting in the kernel,
    i.e. no locking.


    You seem to really love the fast-path. So do I!!!! 100% pure
    lock/wait-free depending on the algorihtm we are targeting. However, we
    can wait on slow paths.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Oct 1 23:51:11 2021
    On 10/1/2021 11:47 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:41 schrieb Chris M. Thomasson:
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:08 schrieb Chris M. Thomasson:

    One cal use lock-free in user-space! A futex or eventcount can be
    used to help it out. You know, if it must wait on an empty
    condition, well, it can without spinning around. If the queue/stack
    is empty, we can wait! Or not. Up to the programmer.

    If you have a slow path you don't have a lock-free algorithm.

    Why not? The slow-path can be avoided, from time to time. ...

    Lock-free is without locking all the time.


    Think of fast path vs slow path. You have a lot to learn!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 08:53:33 2021
    Am 02.10.2021 um 08:51 schrieb Chris M. Thomasson:
    On 10/1/2021 11:47 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:41 schrieb Chris M. Thomasson:
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:08 schrieb Chris M. Thomasson:

    One cal use lock-free in user-space! A futex or eventcount can be
    used to help it out. You know, if it must wait on an empty
    condition, well, it can without spinning around. If the queue/stack
    is empty, we can wait! Or not. Up to the programmer.

    If you have a slow path you don't have a lock-free algorithm.

    Why not? The slow-path can be avoided, from time to time. ...

    Lock-free is without locking all the time.


    Think of fast path vs slow path. You have a lot to learn!

    I know the difference. But lock-free algorithms are
    _always_ non-blocking and _never_ have a slow path.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 08:52:44 2021
    Am 02.10.2021 um 08:50 schrieb Chris M. Thomasson:
    On 10/1/2021 11:46 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:39 schrieb Chris M. Thomasson:
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:12 schrieb Chris M. Thomasson:

    Lock-free is when there's no kernel-locking involved.

    A fast-path can be 100% pure lock/wait-free, so yes; indeed.
    A slow-path  can involve kernel locking. Are you late to the game?

    And if you have kernel-locking you don't have any lock-free algorithm.

    WRONG! Think of the difference between a fast-path and a slow-path.
    The programmer can decide what to do.

    No, not wrong. Lock-free is always without waiting in the kernel,
    i.e. no locking.


    You seem to really love the fast-path. So do I!!!! 100% pure
    lock/wait-free depending on the algorihtm we are targeting.
    However, we can wait on slow paths.

    Lock-free algorithms are _always_ non-blocking,
    so there is never any slow path.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Sat Oct 2 00:01:56 2021
    On 10/1/2021 11:52 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:50 schrieb Chris M. Thomasson:
    On 10/1/2021 11:46 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:39 schrieb Chris M. Thomasson:
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:12 schrieb Chris M. Thomasson:

    Lock-free is when there's no kernel-locking involved.

    A fast-path can be 100% pure lock/wait-free, so yes; indeed.
    A slow-path  can involve kernel locking. Are you late to the game? >>>>>
    And if you have kernel-locking you don't have any lock-free algorithm. >>>>
    WRONG! Think of the difference between a fast-path and a slow-path.
    The programmer can decide what to do.

    No, not wrong. Lock-free is always without waiting in the kernel,
    i.e. no locking.


    You seem to really love the fast-path. So do I!!!! 100% pure
    lock/wait-free depending on the algorihtm we are targeting.
    However, we can wait on slow paths.

    Lock-free algorithms are _always_ non-blocking,
    so there is never any slow path.

    Have you experienced something that required you to wait on certain
    conditions? Call the wait path a slow-path. Make the fast-paths as fast
    as possible. Humm... Are you green?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Sat Oct 2 00:04:55 2021
    On 10/1/2021 11:53 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:51 schrieb Chris M. Thomasson:
    On 10/1/2021 11:47 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:41 schrieb Chris M. Thomasson:
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:08 schrieb Chris M. Thomasson:

    One cal use lock-free in user-space! A futex or eventcount can be
    used to help it out. You know, if it must wait on an empty
    condition, well, it can without spinning around. If the
    queue/stack is empty, we can wait! Or not. Up to the programmer.

    If you have a slow path you don't have a lock-free algorithm.

    Why not? The slow-path can be avoided, from time to time. ...

    Lock-free is without locking all the time.


    Think of fast path vs slow path. You have a lot to learn!

    I know the difference. But lock-free algorithms are
    _always_ non-blocking and _never_ have a slow path.

    ARGH! You are a pain to talk to. There is a way to use this even in
    mutex logic. The slow path of a mutex is when its locked, and we have a
    choice to wait, or perhaps try to do something else... Think about it!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 09:13:01 2021
    Am 02.10.2021 um 09:04 schrieb Chris M. Thomasson:
    On 10/1/2021 11:53 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:51 schrieb Chris M. Thomasson:
    On 10/1/2021 11:47 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:41 schrieb Chris M. Thomasson:
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:08 schrieb Chris M. Thomasson:

    One cal use lock-free in user-space! A futex or eventcount can be >>>>>>> used to help it out. You know, if it must wait on an empty
    condition, well, it can without spinning around. If the
    queue/stack is empty, we can wait! Or not. Up to the programmer.

    If you have a slow path you don't have a lock-free algorithm.

    Why not? The slow-path can be avoided, from time to time. ...

    Lock-free is without locking all the time.


    Think of fast path vs slow path. You have a lot to learn!

    I know the difference. But lock-free algorithms are
    _always_ non-blocking and _never_ have a slow path.

    ARGH! You are a pain to talk to. There is a way to use this even in
    mutex logic. The slow path of a mutex is when its locked, and we have a
      choice to wait, or perhaps try to do something else... Think about it!

    A mutex isn't a lock-free structure because is _also_ has a
    slow path.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 09:12:26 2021
    Am 02.10.2021 um 09:01 schrieb Chris M. Thomasson:
    On 10/1/2021 11:52 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:50 schrieb Chris M. Thomasson:
    On 10/1/2021 11:46 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:39 schrieb Chris M. Thomasson:
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:12 schrieb Chris M. Thomasson:

    Lock-free is when there's no kernel-locking involved.

    A fast-path can be 100% pure lock/wait-free, so yes; indeed.
    A slow-path  can involve kernel locking. Are you late to the game? >>>>>>
    And if you have kernel-locking you don't have any lock-free
    algorithm.

    WRONG! Think of the difference between a fast-path and a slow-path.
    The programmer can decide what to do.

    No, not wrong. Lock-free is always without waiting in the kernel,
    i.e. no locking.


    You seem to really love the fast-path. So do I!!!! 100% pure
    lock/wait-free depending on the algorihtm we are targeting.
    However, we can wait on slow paths.

    Lock-free algorithms are _always_ non-blocking,
    so there is never any slow path.

    Have you experienced something that required you to wait on certain conditions? Call the wait path a slow-path. Make the fast-paths as
    fast as possible. Humm... Are you green?

    There is no slow path with lock-free algorithms.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Sat Oct 2 00:26:29 2021
    On 10/2/2021 12:12 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:01 schrieb Chris M. Thomasson:
    On 10/1/2021 11:52 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:50 schrieb Chris M. Thomasson:
    On 10/1/2021 11:46 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:39 schrieb Chris M. Thomasson:
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:12 schrieb Chris M. Thomasson:

    Lock-free is when there's no kernel-locking involved.

    A fast-path can be 100% pure lock/wait-free, so yes; indeed.
    A slow-path  can involve kernel locking. Are you late to the game? >>>>>>>
    And if you have kernel-locking you don't have any lock-free
    algorithm.

    WRONG! Think of the difference between a fast-path and a
    slow-path. The programmer can decide what to do.

    No, not wrong. Lock-free is always without waiting in the kernel,
    i.e. no locking.


    You seem to really love the fast-path. So do I!!!! 100% pure
    lock/wait-free depending on the algorihtm we are targeting.
    However, we can wait on slow paths.

    Lock-free algorithms are _always_ non-blocking,
    so there is never any slow path.

    Have you experienced something that required you to wait on certain
    conditions? Call the wait path a slow-path. Make the fast-paths as
    fast  as possible. Humm... Are you green?

    There is no slow path with lock-free algorithms.


    What about a stack-empty condition? You seem to be stunted in your
    thinking, for some damn reason. Are you this way on purpose????

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 09:30:57 2021
    Am 02.10.2021 um 09:20 schrieb Chris M. Thomasson:

    A mutex isn't a lock-free structure because is _also_ has a
    slow path.

    It can have a very nice fast-path... Have you ever created one?

    That's not what we're talking about.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 09:31:52 2021
    Am 02.10.2021 um 09:24 schrieb Chris M. Thomasson:

    A mutex isn't a lock-free structure because is _also_ has a
    slow path.

    Have you ever experimented with trying to do something else instead of waiting on a mutex?

    That's not what we're talking about.
    Lock-free is when there is never any waiting in the kernel.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Sat Oct 2 00:31:55 2021
    On 10/1/2021 6:08 AM, Branimir Maksimovic wrote:
    On 2021-10-01, Bonita Montero <Bonita.Montero@gmail.com> wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional
    communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic
    RMW's, just atomic loads, stores, and some some cleverly placed membars. >>>>
    When you use wait-free or lock-free algorithms and there's no data
    you have to poll.

    Why?

    Because you don't have to wait in the kernel.

    If you don't spin it is not lock :P

    True. Hitting the fast path is very nice indeed!

    problem is that only way you don't synchronize
    is when things are *independent* from each other :P


    Well, sometimes one can do other things instead of spinning/waiting,
    even in a mutex locked condition. Its an interesting simple logic loop.
    You have probably seen it before.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Sat Oct 2 00:32:36 2021
    On 10/2/2021 12:30 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:20 schrieb Chris M. Thomasson:

    A mutex isn't a lock-free structure because is _also_ has a
    slow path.

    It can have a very nice fast-path... Have you ever created one?

    That's not what we're talking about.


    I am talking about the nice fast-path being totally lock/wait-free. It
    can! Think about it some more.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Chris M. Thomasson on Sat Oct 2 00:52:21 2021
    On 10/2/2021 12:31 AM, Chris M. Thomasson wrote:
    On 10/1/2021 6:08 AM, Branimir Maksimovic wrote:
    On 2021-10-01, Bonita Montero <Bonita.Montero@gmail.com> wrote:
    Am 30.09.2021 um 22:20 schrieb Chris M. Thomasson:
    On 9/30/2021 3:39 AM, Bonita Montero wrote:
    That's a bit vague. One can create highly efficient bidirectional
    communication between two threads using two wait-free
    single-producer/single-consumer queues without using any atomic
    RMW's, just atomic loads, stores, and some some cleverly placed
    membars.

    When you use wait-free or lock-free algorithms and there's no data
    you have to poll.

    Why?

    Because you don't have to wait in the kernel.

    If you don't spin it is not lock :P

    True. Hitting the fast path is very nice indeed!

    problem is that only way you don't synchronize
    is when things are *independent* from each other :P


    Well, sometimes one can do other things instead of spinning/waiting,
    even in a mutex locked condition. Its an interesting simple logic loop.
    You have probably seen it before.

    Off the top of my head, here is some crude pseudocode to try to get
    across what I am referring to, verbose and not very pretty, fairly
    simple wrt a way to lock a mutex. This was from a long time ago. Fairly adaptive:
    ___________________________
    for (unsigned long i = 0; i < 42; ++i)
    {
    if (try_lock()) return;
    if (! try_to_do_something_else()) break;
    }

    lock();
    ___________________________

    We can try to do other things before we actually wait on the lock. It
    does work, in certain setups.


    This logic above is the most basic I can break it down to.

    Even something that simple can help get things done, "quicker" so to
    speak. The thread tries to do something else, before it waits. It can be
    made to work. And if it fits in with the code at hand, the use case, the
    system we are working on, well, it can be good!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Sat Oct 2 00:24:18 2021
    On 10/2/2021 12:13 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:04 schrieb Chris M. Thomasson:
    On 10/1/2021 11:53 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:51 schrieb Chris M. Thomasson:
    On 10/1/2021 11:47 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:41 schrieb Chris M. Thomasson:
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:08 schrieb Chris M. Thomasson:

    One cal use lock-free in user-space! A futex or eventcount can >>>>>>>> be used to help it out. You know, if it must wait on an empty
    condition, well, it can without spinning around. If the
    queue/stack is empty, we can wait! Or not. Up to the programmer. >>>>>>>
    If you have a slow path you don't have a lock-free algorithm.

    Why not? The slow-path can be avoided, from time to time. ...

    Lock-free is without locking all the time.


    Think of fast path vs slow path. You have a lot to learn!

    I know the difference. But lock-free algorithms are
    _always_ non-blocking and _never_ have a slow path.

    ARGH! You are a pain to talk to. There is a way to use this even in
    mutex logic. The slow path of a mutex is when its locked, and we have
    a    choice to wait, or perhaps try to do something else... Think
    about it!

    A mutex isn't a lock-free structure because is _also_ has a
    slow path.

    Have you ever experimented with trying to do something else instead of
    waiting on a mutex?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Sat Oct 2 00:20:55 2021
    On 10/2/2021 12:13 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:04 schrieb Chris M. Thomasson:
    On 10/1/2021 11:53 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:51 schrieb Chris M. Thomasson:
    On 10/1/2021 11:47 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:41 schrieb Chris M. Thomasson:
    On 10/1/2021 11:38 PM, Bonita Montero wrote:
    Am 02.10.2021 um 08:08 schrieb Chris M. Thomasson:

    One cal use lock-free in user-space! A futex or eventcount can >>>>>>>> be used to help it out. You know, if it must wait on an empty
    condition, well, it can without spinning around. If the
    queue/stack is empty, we can wait! Or not. Up to the programmer. >>>>>>>
    If you have a slow path you don't have a lock-free algorithm.

    Why not? The slow-path can be avoided, from time to time. ...

    Lock-free is without locking all the time.


    Think of fast path vs slow path. You have a lot to learn!

    I know the difference. But lock-free algorithms are
    _always_ non-blocking and _never_ have a slow path.

    ARGH! You are a pain to talk to. There is a way to use this even in
    mutex logic. The slow path of a mutex is when its locked, and we have
    a    choice to wait, or perhaps try to do something else... Think
    about it!

    A mutex isn't a lock-free structure because is _also_ has a
    slow path.

    It can have a very nice fast-path... Have you ever created one?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 10:27:38 2021
    Am 02.10.2021 um 09:32 schrieb Chris M. Thomasson:
    On 10/2/2021 12:31 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:24 schrieb Chris M. Thomasson:

    A mutex isn't a lock-free structure because is _also_ has a
    slow path.

    Have you ever experimented with trying to do something else instead
    of waiting on a mutex?

    That's not what we're talking about.
    Lock-free is when there is never any waiting in the kernel.

    Lock-free is when its lock-free. Ugh!

    Lock-free is when you only have a fast path - and no slow path.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 10:57:51 2021
    Am 02.10.2021 um 10:36 schrieb Chris M. Thomasson:

    Why do you make me want to cough when I read some of your comments? The
    idea is to try to minimize slow-paths... Think about it! Damn it... ;^o

    The idea of lock-free algorithms is not to have slow paths at all.
    Otherwise they wouldn't be lock-free.

    So lock/wait free algorithms are of great use! Not, what did you say, idiotic? Wow.

    No, lock-free algortims involve polling because there is never any kernel-waiting. And polling is out of question.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Sat Oct 2 01:36:07 2021
    On 10/2/2021 1:27 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:32 schrieb Chris M. Thomasson:
    On 10/2/2021 12:31 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:24 schrieb Chris M. Thomasson:

    A mutex isn't a lock-free structure because is _also_ has a
    slow path.

    Have you ever experimented with trying to do something else instead
    of waiting on a mutex?

    That's not what we're talking about.
    Lock-free is when there is never any waiting in the kernel.

    Lock-free is when its lock-free. Ugh!

    Lock-free is when you only have a fast path - and no slow path.

    Why do you make me want to cough when I read some of your comments? The
    idea is to try to minimize slow-paths... Think about it! Damn it... ;^o

    Maximizing Lock/Wait free fast-paths is the main goal here. Gosh... ;^)

    So lock/wait free algorithms are of great use! Not, what did you say,
    idiotic? Wow.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Sat Oct 2 03:03:02 2021
    On 10/2/2021 2:16 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:26 schrieb Chris M. Thomasson:

    There is no slow path with lock-free algorithms.

    What about a stack-empty condition? ...

    Lock-free stacks are used for pooling or handling back resoruces to an
    owning thread.

    Really, is that their only use? Why do you say that, as if its some sort
    of absolute? Why do you seem to project your fairly narrow views on
    others, me? Humm... By the way, you are making me think of a special
    type of per-thread allocator I created in the past, trust me, I have
    been there, done that. Know a lot about them. If thread Z has a node,
    and pushes it onto a stack, well, thread B can pick it up? no? Got it?
    Well, thread B does. ;^)

    There are many VERY fun things we can do wrt a granularity of
    lock/wait-free mechanisms. Try to pull your head out of the sand for a
    moment? Sigh.


    In the first case the thread not finding any preallocated
    items on the stack allocates them conventionally - and that has nothing
    to do with locking - and in the latter case if the thread given back the resources doesn't find something on the stack it simply doesn't empty
    the stack. If he would find sth. on the stack it would empty it and
    put back the resoruces in its local pools.
    So there's nothing wigh locking in either case.

    I'm talking to a complete moron here.

    Argh! I actually do have experience here. You push me away. Really? I
    thought we could talk about these most interesting things... You have potential!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 11:16:03 2021
    Am 02.10.2021 um 09:26 schrieb Chris M. Thomasson:

    There is no slow path with lock-free algorithms.

    What about a stack-empty condition? ...

    Lock-free stacks are used for pooling or handling back resoruces to an
    owning thread. In the first case the thread not finding any preallocated
    items on the stack allocates them conventionally - and that has nothing
    to do with locking - and in the latter case if the thread given back the resources doesn't find something on the stack it simply doesn't empty
    the stack. If he would find sth. on the stack it would empty it and
    put back the resoruces in its local pools.
    So there's nothing wigh locking in either case.

    I'm talking to a complete moron here.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 13:06:15 2021
    Am 02.10.2021 um 12:03 schrieb Chris M. Thomasson:

    Lock-free stacks are used for pooling or handling back resoruces to an
    owning thread.

    Really, is that their only use? ..

    Yes.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 2 13:07:05 2021
    Am 02.10.2021 um 13:06 schrieb Bonita Montero:
    Am 02.10.2021 um 12:03 schrieb Chris M. Thomasson:

    Lock-free stacks are used for pooling or handling back resoruces to an
    owning thread.

    Really, is that their only use? ..

    Yes.

    Or more precisely: pracitcally yes. Because other uses aren't
    practicable because of the drawbacks of lock-free algorithms.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From RadicalRabbit@theburrow.co.uk@21:1/5 to Chris M. Thomasson on Sun Oct 3 08:25:57 2021
    On Fri, 1 Oct 2021 13:11:21 -0700
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 2:17 AM, RadicalRabbit@theburrow.co.uk wrote:
    On Thu, 30 Sep 2021 13:00:53 -0700
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
    On 9/29/2021 12:09 PM, Chris M. Thomasson wrote:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might >>>>> be thrown. These states are all true or false so I combined them to a >>>>> four bit pattern wich I used as an index to a table which stores the >>>>> strings of the out_of_range exception to be trown or a nullptr if the >>>>> state isn't associated with an out of range condition. This helps me >>>>> to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the >>>>> code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Have you posted the whole dual_monitor code? If you did, I missed it.
    Sorry.


    In the mean time, I am working on another fractal set to music. Like
    these I did last year:

    https://youtu.be/DSiWvF5QOiI

    https://youtu.be/QFPSYsYUKBA

    Very impressive.

    Thank you very much for the kind comment! :^)


    Could use maybe a few more colours though.

    Yeah, they could. Humm... I am working on another animation using a more >robust coloring algorithm for the field lines. Here is an example:

    https://fractalforums.org/gallery/1612-300921002353.png

    That looks much more sophisticated.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to RadicalRabbit@theburrow.co.uk on Sun Oct 3 13:21:05 2021
    On 10/3/2021 1:25 AM, RadicalRabbit@theburrow.co.uk wrote:
    On Fri, 1 Oct 2021 13:11:21 -0700
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 2:17 AM, RadicalRabbit@theburrow.co.uk wrote:
    On Thu, 30 Sep 2021 13:00:53 -0700
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
    On 9/29/2021 12:09 PM, Chris M. Thomasson wrote:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might >>>>>> be thrown. These states are all true or false so I combined them to a >>>>>> four bit pattern wich I used as an index to a table which stores the >>>>>> strings of the out_of_range exception to be trown or a nullptr if the >>>>>> state isn't associated with an out of range condition. This helps me >>>>>> to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the >>>>>> code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Have you posted the whole dual_monitor code? If you did, I missed it. >>>>> Sorry.


    In the mean time, I am working on another fractal set to music. Like
    these I did last year:

    https://youtu.be/DSiWvF5QOiI

    https://youtu.be/QFPSYsYUKBA

    Very impressive.

    Thank you very much for the kind comment! :^)


    Could use maybe a few more colours though.

    Yeah, they could. Humm... I am working on another animation using a more
    robust coloring algorithm for the field lines. Here is an example:

    https://fractalforums.org/gallery/1612-300921002353.png

    That looks much more sophisticated.


    It does! Thanks. Fwiw, here is another interesting zoom on a spiral
    formation using the experimental coloring algorihtm:

    https://fractalforums.org/gallery/1612-031021065422.png

    Now, when I am finished with my new animation, I am going to cycle the
    colors using an interpolation across the frames. It should look really
    strange, and mesmerizing. That's the goal. ;^)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Sun Oct 3 13:33:23 2021
    On 10/1/2021 1:54 PM, Branimir Maksimovic wrote:
    On 2021-10-01, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 6:07 AM, Branimir Maksimovic wrote:
    On 2021-09-30, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote: >>>> On 9/29/2021 12:09 PM, Chris M. Thomasson wrote:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might >>>>>> be thrown. These states are all true or false so I combined them to a >>>>>> four bit pattern wich I used as an index to a table which stores the >>>>>> strings of the out_of_range exception to be trown or a nullptr if the >>>>>> state isn't associated with an out of range condition. This helps me >>>>>> to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the >>>>>> code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Have you posted the whole dual_monitor code? If you did, I missed it. >>>>> Sorry.


    In the mean time, I am working on another fractal set to music. Like
    these I did last year:

    https://youtu.be/DSiWvF5QOiI

    https://youtu.be/QFPSYsYUKBA
    An error occurred. Please try again later. (Playback ID: pHR4vgIqqp13ECHz) >>> Learn More


    That's odd. The links I posted work for me. Just checked them. Humm...
    Safari, iCloud private relay.... ipv6


    Humm... Can you see any of my work on YouTube? Here is my channel:

    https://www.youtube.com/channel/UC_DhsJu-AbQ6Msnxdf8z6Kg

    Does that link work for you?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Sun Oct 3 21:06:44 2021
    On 2021-10-03, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/3/2021 1:25 AM, RadicalRabbit@theburrow.co.uk wrote:
    On Fri, 1 Oct 2021 13:11:21 -0700
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 2:17 AM, RadicalRabbit@theburrow.co.uk wrote:
    On Thu, 30 Sep 2021 13:00:53 -0700
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
    On 9/29/2021 12:09 PM, Chris M. Thomasson wrote:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might >>>>>>> be thrown. These states are all true or false so I combined them to a >>>>>>> four bit pattern wich I used as an index to a table which stores the >>>>>>> strings of the out_of_range exception to be trown or a nullptr if the >>>>>>> state isn't associated with an out of range condition. This helps me >>>>>>> to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the >>>>>>> code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Have you posted the whole dual_monitor code? If you did, I missed it. >>>>>> Sorry.


    In the mean time, I am working on another fractal set to music. Like >>>>> these I did last year:

    https://youtu.be/DSiWvF5QOiI

    https://youtu.be/QFPSYsYUKBA

    Very impressive.

    Thank you very much for the kind comment! :^)


    Could use maybe a few more colours though.

    Yeah, they could. Humm... I am working on another animation using a more >>> robust coloring algorithm for the field lines. Here is an example:

    https://fractalforums.org/gallery/1612-300921002353.png

    That looks much more sophisticated.


    It does! Thanks. Fwiw, here is another interesting zoom on a spiral
    formation using the experimental coloring algorihtm:

    https://fractalforums.org/gallery/1612-031021065422.png

    Now, when I am finished with my new animation, I am going to cycle the
    colors using an interpolation across the frames. It should look really strange, and mesmerizing. That's the goal. ;^)
    What about this (not mine work): https://www.icloud.com/iclouddrive/0sLxM6sxtszTkGEX_3YwH57bA#mandelbrot
    proggy:
    format ELF64 executable 3
    entry start
    segment readable executable ;============================================================================== macro IACA_START {
    ; mov ebx,111
    ; db 0x64,0x67,0x90
    }
    macro IACA_END {
    ; mov ebx,222
    ; db 0x64,0x67,0x90
    } ;==============================================================================
    align 16
    compute_color:
    ; in: <ymm0>, <ymm1> normalized x, y coordinates
    ; out: <ymm0>, <ymm1>, <ymm2> r, g, b color components ;------------------------------------------------------------------------------
    vaddps ymm0,ymm0,[.c_xoffset]
    vxorps ymm2,ymm2,ymm2 ; ymm2 = x
    vmovaps ymm3,ymm2 ; ymm3 = y
    vmovaps ymm4,ymm2 ; ymm4 = x^2
    vmovaps ymm5,ymm2 ; ymm5 = y^2
    vxorps ymm8,ymm8,ymm8
    mov eax,256
    align 32
    .loop:
    IACA_START ; 12.00 cycles on HSW
    vmulps ymm3,ymm2,ymm3 ; ymm3 = x*y
    vsubps ymm2,ymm4,ymm5 ; ymm2 = x^2 - y^2
    vaddps ymm3,ymm3,ymm3 ; ymm3 = 2*x*y
    vaddps ymm2,ymm2,ymm0 ; ymm2 = xn = x^2 - y^2 + a
    vaddps ymm3,ymm3,ymm1 ; ymm3 = yn = 2*x*y + b
    vmulps ymm4,ymm2,ymm2 ; ymm4 = xn^2
    vmulps ymm5,ymm3,ymm3 ; ymm5 = yn^2
    vaddps ymm6,ymm2,ymm3 ; ymm6 = xn^2 + yn^2 = m2
    vcmpltps ymm7,ymm6,[.c_4_0]
    vandnps ymm7,ymm7,[.c_1_0]
    vaddps ymm8,ymm8,ymm7
    sub eax,1
    jnz .loop
    IACA_END
    vmovaps ymm0,ymm8
    vdivps ymm0,ymm0,[.c_255_0]
    vmulps ymm0,ymm0,ymm0
    vmulps ymm0,ymm0,ymm0
    vmulps ymm0,ymm0,ymm0
    vmovaps ymm1,ymm0
    vmovaps ymm2,ymm0
    ret
    align 32
    .c_4_0: dd 8 dup 4.0
    .c_1_0: dd 8 dup 1.0
    .c_255_0: dd 8 dup 255.0
    .c_xoffset: dd 8 dup -0.5 ;==============================================================================
    align 16
    thread: ;------------------------------------------------------------------------------
    virtual at rsp
    .startx dd ?
    .starty dd ?
    end virtual
    push rbp rbx
    mov rbp,rsp
    sub rsp,32
    and rsp,-32
    .tile:
    mov r15d,1
    lock xadd [image_tile],r15d
    cmp r15d,TILE_COUNT
    jge .finish
    xor edx,edx
    mov eax,r15d
    mov edi,TILE_X_COUNT
    div edi
    imul eax,TILE_SIZE
    imul edx,TILE_SIZE
    mov [.startx],edx
    mov [.starty],eax
    imul eax,IMAGE_SIZE
    add eax,edx
    shl eax,2
    mov rbx,[image_ptr]
    add rbx,rax
    xor r14d,r14d
    .row:
    xor r13d,r13d
    align 16
    .pixel:
    mov edx,[.startx]
    mov eax,[.starty]
    add edx,r13d
    add eax,r14d
    ;------------------------------------ compute color
    vmovaps ymm2,[image_size]
    vmovaps ymm3,ymm2
    vrcpps ymm3,ymm3
    vcvtsi2ss xmm0,xmm0,edx
    vcvtsi2ss xmm1,xmm1,eax
    vbroadcastss ymm0,xmm0
    vbroadcastss ymm1,xmm1
    vaddps ymm0,ymm0,[.c_01234567f]
    vaddps ymm1,ymm1,ymm1
    vaddps ymm0,ymm0,ymm0
    vsubps ymm0,ymm0,ymm2
    vsubps ymm1,ymm1,ymm2
    vmulps ymm0,ymm0,ymm3
    vmulps ymm1,ymm1,ymm3
    call compute_color
    ;------------------------------------ convert color from RGB32F to BGRA8
    vxorps ymm3,ymm3,ymm3
    vmovaps ymm4,[.c_1_0]
    vminps ymm0,ymm0,ymm4
    vminps ymm1,ymm1,ymm4
    vminps ymm2,ymm2,ymm4
    vmaxps ymm0,ymm0,ymm3
    vmaxps ymm1,ymm1,ymm3
    vmaxps ymm2,ymm2,ymm3
    vmovaps ymm3,[.c_255_0]
    vmulps ymm0,ymm0,ymm3
    vmulps ymm1,ymm1,ymm3
    vmulps ymm2,ymm2,ymm3
    vcvttps2dq ymm0,ymm0
    vcvttps2dq ymm1,ymm1
    vcvttps2dq ymm2,ymm2
    vpslld ymm1,ymm1,8
    vpslld ymm0,ymm0,16
    vpor ymm0,ymm0,[.c_ff000000]
    vpor ymm1,ymm1,ymm2
    vpor ymm0,ymm0,ymm1
    vmovdqa [rbx+r13*4],ymm0
    ;------------------------------------
    add r13d,8
    cmp r13d,TILE_SIZE
    jne .pixel
    add rbx,IMAGE_SIZE*4
    add r14d,1
    cmp r14d,TILE_SIZE
    jne .row
    jmp .tile
    .finish:
    mov rsp,rbp
    pop rbx rbp
    ret
    align 32
    .c_01234567f: dd 0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0
    .c_1_0: dd 8 dup 1.0
    .c_255_0: dd 8 dup 255.0
    .c_ff000000: dd 8 dup 0xff000000 ;==============================================================================
    align 16
    mem_alloc:
    ; in: <rdi> size in bytes
    ; out: <rax> pointer to the allocated memory ;------------------------------------------------------------------------------
    mov eax,9 ; sys_mmap
    mov rsi,rdi ; length
    xor edi,edi ; addr
    mov edx,0x1+0x2 ; PROT_READ | PROT_WRITE
    mov r10d,0x02+0x20 ; MAP_PRIVATE | MAP_ANONYMOUS
    mov r8,-1 ; fd
    xor r9d,r9d ; offset
    syscall
    ret ;==============================================================================
    align 16
    thread_create:
    ; in: <rbx> mutex address ;------------------------------------------------------------------------------
    mov edi,4096
    call mem_alloc
    mov rsi,rax
    add rsi,4096
    mov eax,56 ; sys_clone
    mov edi,0x100+0x200+0x400+0x800+0x10000
    xor edx,edx
    syscall
    test eax,eax
    jnz .ret
    call thread
    mov dword [rbx],1
    mov eax,202 ; sys_futex
    mov rdi,rbx ; mutex address
    mov esi,1 ; FUTEX_WAKE
    mov edx,1 ; wake 1 thread
    syscall
    mov eax,60 ; sys_exit
    xor edi,edi ; exit code
    syscall
    .ret:
    ret ;==============================================================================
    align 16
    thread_wait:
    ; in: <rbx> mutex address ;------------------------------------------------------------------------------
    mov eax,202 ; sys_futex
    mov rdi,rbx ; mutex address
    mov esi,0 ; FUTEX_WAIT
    mov edx,0 ; mutex 'running' value
    xor r10d,r10d ; unused but must be zero
    syscall
    ret ;==============================================================================
    align 16
    image_save: ;------------------------------------------------------------------------------
    push rbx
    mov eax,85
    mov rdi,.tga_name
    mov esi,110000000b
    syscall
    mov rbx,rax
    mov eax,1
    mov rdi,rbx
    mov rsi,.tga_head
    mov edx,18
    syscall
    mov eax,1
    mov rdi,rbx
    mov rsi,[image_ptr]
    mov edx,IMAGE_SIZE*IMAGE_SIZE*4
    syscall
    pop rbx
    ret
    .tga_name db 'mandelbrot.tga',0
    .tga_head db 0,0,2,9 dup 0
    db (IMAGE_SIZE and 0x00ff),(IMAGE_SIZE and 0xff00) shr 8
    db (IMAGE_SIZE and 0x00ff),(IMAGE_SIZE and 0xff00) shr 8,32,0 ;==============================================================================
    align 16
    main: ;------------------------------------------------------------------------------
    mov rdi,IMAGE_SIZE*IMAGE_SIZE*4
    call mem_alloc
    mov [image_ptr],rax
    mov rbx,thread0_mutex
    call thread_create
    mov rbx,thread1_mutex
    call thread_create
    mov rbx,thread2_mutex
    call thread_create
    mov rbx,thread3_mutex
    call thread_create
    mov rbx,thread0_mutex
    call thread_wait
    mov rbx,thread1_mutex
    call thread_wait
    mov rbx,thread2_mutex
    call thread_wait
    mov rbx,thread3_mutex
    call thread_wait
    call image_save
    ret ;==============================================================================
    align 16
    start: ;------------------------------------------------------------------------------
    call main
    mov eax,60 ; sys_exit
    xor edi,edi ; exit code
    syscall ;============================================================================== segment readable writeable

    align 4
    thread0_mutex dd 0
    thread1_mutex dd 0
    thread2_mutex dd 0
    thread3_mutex dd 0

    align 8
    image_ptr dq 0
    align 4
    image_tile dd 0

    TILE_SIZE = 64
    TILE_X_COUNT = IMAGE_SIZE / TILE_SIZE
    TILE_Y_COUNT = IMAGE_SIZE / TILE_SIZE
    TILE_COUNT = TILE_X_COUNT * TILE_Y_COUNT
    IMAGE_SIZE = 1024

    align 32
    image_size: dd 8 dup 1024.0 ;==============================================================================


    --

    7-77-777
    Evil Sinner!
    to weak you should be meek, and you should brainfuck stronger https://github.com/rofl0r/chaos-pp

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Sun Oct 3 21:07:53 2021
    On 2021-10-03, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:

    Humm... Can you see any of my work on YouTube? Here is my channel:

    https://www.youtube.com/channel/UC_DhsJu-AbQ6Msnxdf8z6Kg

    Does that link work for you?

    Bookmarked, will enjoy, THANKS!

    --

    7-77-777
    Evil Sinner!
    to weak you should be meek, and you should brainfuck stronger https://github.com/rofl0r/chaos-pp

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Sun Oct 3 14:33:07 2021
    On 10/3/2021 2:06 PM, Branimir Maksimovic wrote:
    On 2021-10-03, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/3/2021 1:25 AM, RadicalRabbit@theburrow.co.uk wrote:
    On Fri, 1 Oct 2021 13:11:21 -0700
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 2:17 AM, RadicalRabbit@theburrow.co.uk wrote:
    On Thu, 30 Sep 2021 13:00:53 -0700
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
    On 9/29/2021 12:09 PM, Chris M. Thomasson wrote:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception might
    be thrown. These states are all true or false so I combined them to a >>>>>>>> four bit pattern wich I used as an index to a table which stores the >>>>>>>> strings of the out_of_range exception to be trown or a nullptr if the >>>>>>>> state isn't associated with an out of range condition. This helps me >>>>>>>> to prevent some if-else-cascades and speeds up the code.
    So this is the complete function but i put two empty lines around the >>>>>>>> code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Have you posted the whole dual_monitor code? If you did, I missed it. >>>>>>> Sorry.


    In the mean time, I am working on another fractal set to music. Like >>>>>> these I did last year:

    https://youtu.be/DSiWvF5QOiI

    https://youtu.be/QFPSYsYUKBA

    Very impressive.

    Thank you very much for the kind comment! :^)


    Could use maybe a few more colours though.

    Yeah, they could. Humm... I am working on another animation using a more >>>> robust coloring algorithm for the field lines. Here is an example:

    https://fractalforums.org/gallery/1612-300921002353.png

    That looks much more sophisticated.


    It does! Thanks. Fwiw, here is another interesting zoom on a spiral
    formation using the experimental coloring algorihtm:

    https://fractalforums.org/gallery/1612-031021065422.png

    Now, when I am finished with my new animation, I am going to cycle the
    colors using an interpolation across the frames. It should look really
    strange, and mesmerizing. That's the goal. ;^)
    What about this (not mine work): https://www.icloud.com/iclouddrive/0sLxM6sxtszTkGEX_3YwH57bA#mandelbrot proggy:
    format ELF64 executable 3
    [...]

    Definite field lines. Not sure if its using binary decomposition.
    Actually, check these out. Its from a field line algorithm I created for
    escape time fractals:

    https://fractalforums.org/fractal-mathematics-and-new-theories/28/plotting-field-lines-during-iteration/4233

    It was mentioned here:

    https://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/MandelbrotSetExteriorComplex_potential

    Search for my last name in the page:

    http://www.fractalforums.com/new-theories-and-research/plotting-field-lines-during-iteration/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Sun Oct 3 14:51:23 2021
    On 10/3/2021 2:07 PM, Branimir Maksimovic wrote:
    On 2021-10-03, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:

    Humm... Can you see any of my work on YouTube? Here is my channel:

    https://www.youtube.com/channel/UC_DhsJu-AbQ6Msnxdf8z6Kg

    Does that link work for you?

    Bookmarked, will enjoy, THANKS!


    No problem. Glad you can see them. Also, fwiw, here is my vector field
    rendered in real time using a GLSL shader:

    https://www.shadertoy.com/view/MdcyRs

    You can press and drag a point around in the animation to create an
    attractor in the field. Also, he is my field using WebGL:

    http://fractallife247.com/test/webgl/

    Does it work for you? Thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Mon Oct 4 04:42:36 2021
    On 2021-10-03, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/3/2021 2:06 PM, Branimir Maksimovic wrote:
    On 2021-10-03, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/3/2021 1:25 AM, RadicalRabbit@theburrow.co.uk wrote:
    On Fri, 1 Oct 2021 13:11:21 -0700 "Chris M. Thomasson"
    <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 2:17 AM, RadicalRabbit@theburrow.co.uk wrote:
    On Thu, 30 Sep 2021 13:00:53 -0700 "Chris M. Thomasson"
    <chris.m.thomasson.1@gmail.com> wrote:
    On 9/29/2021 12:09 PM, Chris M. Thomasson wrote:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception >>>>>>>>> might be thrown. These states are all true or false so I combined >>>>>>>>> them to a four bit pattern wich I used as an index to a table which >>>>>>>>> stores the strings of the out_of_range exception to be trown or a >>>>>>>>> nullptr if the state isn't associated with an out of range condition. >>>>>>>>> This helps me to prevent some if-else-cascades and speeds up the >>>>>>>>> code. So this is the complete function but i put two empty lines >>>>>>>>> around the code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Have you posted the whole dual_monitor code? If you did, I missed it. >>>>>>>> Sorry.


    In the mean time, I am working on another fractal set to music. Like >>>>>>> these I did last year:

    https://youtu.be/DSiWvF5QOiI

    https://youtu.be/QFPSYsYUKBA

    Very impressive.

    Thank you very much for the kind comment! :^)


    Could use maybe a few more colours though.

    Yeah, they could. Humm... I am working on another animation using a more >>>>> robust coloring algorithm for the field lines. Here is an example:

    https://fractalforums.org/gallery/1612-300921002353.png

    That looks much more sophisticated.


    It does! Thanks. Fwiw, here is another interesting zoom on a spiral
    formation using the experimental coloring algorihtm:

    https://fractalforums.org/gallery/1612-031021065422.png

    Now, when I am finished with my new animation, I am going to cycle the
    colors using an interpolation across the frames. It should look really
    strange, and mesmerizing. That's the goal. ;^)
    What about this (not mine work):
    https://www.icloud.com/iclouddrive/0sLxM6sxtszTkGEX_3YwH57bA#mandelbrot
    proggy: format ELF64 executable 3
    [...]

    Definite field lines. Not sure if its using binary decomposition. Actually, check these out. Its from a field line algorithm I created for escape time fractals:

    https://fractalforums.org/fractal-mathematics-and-new-theories/28/plotting-field-lines-during-iteration/4233

    It was mentioned here:

    https://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/MandelbrotSetExteriorComplex_potential

    Search for my last name in the page:

    http://www.fractalforums.com/new-theories-and-research/plotting-field-lines-during-iteration/

    Found, THANKS!

    --

    7-77-777
    Evil Sinner!
    to weak you should be meek, and you should brainfuck stronger https://github.com/rofl0r/chaos-pp

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Mon Oct 4 04:44:40 2021
    On 2021-10-03, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    No problem. Glad you can see them. Also, fwiw, here is my vector field rendered in real time using a GLSL shader:

    https://www.shadertoy.com/view/MdcyRs

    You can press and drag a point around in the animation to create an attractor in the field. Also, he is my field using WebGL:

    http://fractallife247.com/test/webgl/

    Does it work for you? Thanks.
    Both work on Safari, thanks.

    --

    7-77-777
    Evil Sinner!
    to weak you should be meek, and you should brainfuck stronger https://github.com/rofl0r/chaos-pp

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Mon Oct 4 01:19:57 2021
    On 9/25/2021 8:46 PM, Bonita Montero wrote:
    Am 25.09.2021 um 19:22 schrieb Branimir Maksimovic:
    On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:

    And you use unreliable function for that?

    Show me where my code is unreliable.
    I think you're simply a poor troll.
    I am just asking because you build something
    on shaken ground. Why do you think is reliable,
    simple question?

    Because the code is simple.


    Have you posted the entire code for your dual_monitor algorihtm?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Mon Oct 4 13:50:57 2021
    Am 04.10.2021 um 10:19 schrieb Chris M. Thomasson:
    On 9/25/2021 8:46 PM, Bonita Montero wrote:
    Am 25.09.2021 um 19:22 schrieb Branimir Maksimovic:
    On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:

    And you use unreliable function for that?

    Show me where my code is unreliable.
    I think you're simply a poor troll.
    I am just asking because you build something
    on shaken ground. Why do you think is reliable,
    simple question?

    Because the code is simple.


    Have you posted the entire code for your dual_monitor algorihtm?

    You won't understand it.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?B?w5bDtiBUaWli?=@21:1/5 to Chris M. Thomasson on Mon Oct 4 08:50:18 2021
    On Monday, 4 October 2021 at 11:20:13 UTC+3, Chris M. Thomasson wrote:
    On 9/25/2021 8:46 PM, Bonita Montero wrote:
    Am 25.09.2021 um 19:22 schrieb Branimir Maksimovic:
    On 2021-09-25, Bonita Montero <Bonita....@gmail.com> wrote:

    And you use unreliable function for that?

    Show me where my code is unreliable.
    I think you're simply a poor troll.
    I am just asking because you build something
    on shaken ground. Why do you think is reliable,
    simple question?

    Because the code is simple.


    Have you posted the entire code for your dual_monitor algorihtm?

    BMs threads are busily spinning when nothing to do so
    it is hard to find utilization to it (besides of as bad example).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Mon Oct 4 10:08:05 2021
    On 10/4/2021 4:50 AM, Bonita Montero wrote:
    Am 04.10.2021 um 10:19 schrieb Chris M. Thomasson:
    On 9/25/2021 8:46 PM, Bonita Montero wrote:
    Am 25.09.2021 um 19:22 schrieb Branimir Maksimovic:
    On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:

    And you use unreliable function for that?

    Show me where my code is unreliable.
    I think you're simply a poor troll.
    I am just asking because you build something
    on shaken ground. Why do you think is reliable,
    simple question?

    Because the code is simple.


    Have you posted the entire code for your dual_monitor algorihtm?

    You won't understand it.


    Why not? I need to see the whole thing instead of just
    dual_monitor::wait... See?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to All on Mon Oct 4 10:07:31 2021
    On 10/4/2021 8:50 AM, Öö Tiib wrote:
    On Monday, 4 October 2021 at 11:20:13 UTC+3, Chris M. Thomasson wrote:
    On 9/25/2021 8:46 PM, Bonita Montero wrote:
    Am 25.09.2021 um 19:22 schrieb Branimir Maksimovic:
    On 2021-09-25, Bonita Montero <Bonita....@gmail.com> wrote:

    And you use unreliable function for that?

    Show me where my code is unreliable.
    I think you're simply a poor troll.
    I am just asking because you build something
    on shaken ground. Why do you think is reliable,
    simple question?

    Because the code is simple.


    Have you posted the entire code for your dual_monitor algorihtm?

    BMs threads are busily spinning when nothing to do so
    it is hard to find utilization to it (besides of as bad example).


    I am interested in look at her full code for dual_monitor. Also, this
    thread has a lot of interesting information in it. Well, imvho...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Mon Oct 4 11:31:32 2021
    On 10/2/2021 1:27 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:32 schrieb Chris M. Thomasson:
    On 10/2/2021 12:30 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:20 schrieb Chris M. Thomasson:

    A mutex isn't a lock-free structure because is _also_ has a
    slow path.

    It can have a very nice fast-path... Have you ever created one?

    That's not what we're talking about.


    I am talking about the nice fast-path being totally lock/wait-free. It
    can! Think about it some more.

    Lock-free is when you only have a fast path - and no slow path.

    Why not combine the two? Ahhh, the futex, or eventcount.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Tue Oct 5 07:13:32 2021
    Am 04.10.2021 um 20:31 schrieb Chris M. Thomasson:
    On 10/2/2021 1:27 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:32 schrieb Chris M. Thomasson:
    On 10/2/2021 12:30 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:20 schrieb Chris M. Thomasson:

    A mutex isn't a lock-free structure because is _also_ has a
    slow path.

    It can have a very nice fast-path... Have you ever created one?

    That's not what we're talking about.


    I am talking about the nice fast-path being totally lock/wait-free.
    It can! Think about it some more.

    Lock-free is when you only have a fast path - and no slow path.

    Why not combine the two? Ahhh, the futex, or eventcount.

    Then it's not lock-free anymore.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Wed Oct 6 12:22:42 2021
    On 10/4/2021 10:13 PM, Bonita Montero wrote:
    Am 04.10.2021 um 20:31 schrieb Chris M. Thomasson:
    On 10/2/2021 1:27 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:32 schrieb Chris M. Thomasson:
    On 10/2/2021 12:30 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:20 schrieb Chris M. Thomasson:

    A mutex isn't a lock-free structure because is _also_ has a
    slow path.

    It can have a very nice fast-path... Have you ever created one?

    That's not what we're talking about.


    I am talking about the nice fast-path being totally lock/wait-free.
    It can! Think about it some more.

    Lock-free is when you only have a fast path - and no slow path.

    Why not combine the two? Ahhh, the futex, or eventcount.

    Then it's not lock-free anymore.

    However, it has lock-free fast-paths. That is a huge advantage!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Wed Oct 6 18:11:06 2021
    On 10/3/2021 9:42 PM, Branimir Maksimovic wrote:
    On 2021-10-03, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/3/2021 2:06 PM, Branimir Maksimovic wrote:
    On 2021-10-03, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote: >>>> On 10/3/2021 1:25 AM, RadicalRabbit@theburrow.co.uk wrote:
    On Fri, 1 Oct 2021 13:11:21 -0700 "Chris M. Thomasson"
    <chris.m.thomasson.1@gmail.com> wrote:
    On 10/1/2021 2:17 AM, RadicalRabbit@theburrow.co.uk wrote:
    On Thu, 30 Sep 2021 13:00:53 -0700 "Chris M. Thomasson"
    <chris.m.thomasson.1@gmail.com> wrote:
    On 9/29/2021 12:09 PM, Chris M. Thomasson wrote:
    On 9/20/2021 1:43 PM, Bonita Montero wrote:
    In some code I've to check different sates for which an exception >>>>>>>>>> might be thrown. These states are all true or false so I combined >>>>>>>>>> them to a four bit pattern wich I used as an index to a table which >>>>>>>>>> stores the strings of the out_of_range exception to be trown or a >>>>>>>>>> nullptr if the state isn't associated with an out of range condition.
    This helps me to prevent some if-else-cascades and speeds up the >>>>>>>>>> code. So this is the complete function but i put two empty lines >>>>>>>>>> around the code I mentioned.

    void dual_monitor::wait( bool b )
    [...]

    Have you posted the whole dual_monitor code? If you did, I missed it. >>>>>>>>> Sorry.


    In the mean time, I am working on another fractal set to music. Like >>>>>>>> these I did last year:

    https://youtu.be/DSiWvF5QOiI

    https://youtu.be/QFPSYsYUKBA

    Very impressive.

    Thank you very much for the kind comment! :^)


    Could use maybe a few more colours though.

    Yeah, they could. Humm... I am working on another animation using a more >>>>>> robust coloring algorithm for the field lines. Here is an example: >>>>>>
    https://fractalforums.org/gallery/1612-300921002353.png

    That looks much more sophisticated.


    It does! Thanks. Fwiw, here is another interesting zoom on a spiral
    formation using the experimental coloring algorihtm:

    https://fractalforums.org/gallery/1612-031021065422.png

    Now, when I am finished with my new animation, I am going to cycle the >>>> colors using an interpolation across the frames. It should look really >>>> strange, and mesmerizing. That's the goal. ;^)
    What about this (not mine work):
    https://www.icloud.com/iclouddrive/0sLxM6sxtszTkGEX_3YwH57bA#mandelbrot
    proggy: format ELF64 executable 3
    [...]

    Definite field lines. Not sure if its using binary decomposition. Actually, >> check these out. Its from a field line algorithm I created for escape time >> fractals:

    https://fractalforums.org/fractal-mathematics-and-new-theories/28/plotting-field-lines-during-iteration/4233

    It was mentioned here:

    https://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/MandelbrotSetExteriorComplex_potential

    Search for my last name in the page:

    http://www.fractalforums.com/new-theories-and-research/plotting-field-lines-during-iteration/

    Found, THANKS!


    No problem. Fwiw, here is a new test animation I made:

    https://youtu.be/nPR4xK-5i4I

    https://www.youtube.com/watch?v=nPR4xK-5i4I

    Both links work for me. How many work for you? Just wondering.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Wed Oct 6 17:19:22 2021
    On 10/2/2021 1:57 AM, Bonita Montero wrote:
    Am 02.10.2021 um 10:36 schrieb Chris M. Thomasson:

    Why do you make me want to cough when I read some of your comments?
    The idea is to try to minimize slow-paths... Think about it! Damn
    it... ;^o

    The idea of lock-free algorithms is not to have slow paths at all.

    Why not? You have a very narrow view. A pure lock-free fast-path is
    ideal. A wait-free fast-path is even better!

    Otherwise they wouldn't be lock-free.

    Forgot about that all or nothing line of thought for a moment. Think
    outside of the box, so to speak...


    So lock/wait free algorithms are of great use! Not, what did you say,
    idiotic? Wow.

    No, lock-free algortims involve polling because there is never any kernel-waiting. And polling is out of question.

    ARGH! Try to pull your head out of the proverbial sand for a moment? A lock/wait-free fast-path is great!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Wed Oct 6 18:22:33 2021
    On 10/2/2021 4:07 AM, Bonita Montero wrote:
    Am 02.10.2021 um 13:06 schrieb Bonita Montero:
    Am 02.10.2021 um 12:03 schrieb Chris M. Thomasson:

    Lock-free stacks are used for pooling or handling back resoruces to an >>>> owning thread.

    Really, is that their only use? ..

    Yes.

    Or more precisely: pracitcally yes. Because other uses aren't
    practicable because of the drawbacks of lock-free algorithms.



    think outside of the box.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Thu Oct 7 02:17:14 2021
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    ideal. A wait-free fast-path is even better!

    Then, you have to think what to do, when there is is nothing
    to do :P

    --

    7-77-777
    Evil Sinner!
    to weak you should be meek, and you should brainfuck stronger https://github.com/rofl0r/chaos-pp

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Thu Oct 7 02:20:07 2021
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:

    No problem. Fwiw, here is a new test animation I made:

    https://youtu.be/nPR4xK-5i4I

    https://www.youtube.com/watch?v=nPR4xK-5i4I

    Both links work for me. How many work for you? Just wondering.
    Watched, beautiful
    Thanks!
    --

    7-77-777
    Evil Sinner!
    to weak you should be meek, and you should brainfuck stronger https://github.com/rofl0r/chaos-pp

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Wed Oct 6 19:38:40 2021
    On 10/6/2021 7:17 PM, Branimir Maksimovic wrote:
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    ideal. A wait-free fast-path is even better!

    Then, you have to think what to do, when there is is nothing
    to do :P


    When the fast-path fails, we can choose to try to wait. Usually on a
    Futex or Eventcount. The main idea is under periods of load, when the
    structure is not empty, we can fly along lock/wait-free paths.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Thu Oct 7 02:45:59 2021
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/6/2021 7:17 PM, Branimir Maksimovic wrote:
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    ideal. A wait-free fast-path is even better!

    Then, you have to think what to do, when there is is nothing
    to do :P


    When the fast-path fails, we can choose to try to wait. Usually on a
    Futex or Eventcount. The main idea is under periods of load, when the structure is not empty, we can fly along lock/wait-free paths.

    iWhat you think about this code:
    while(true){
    usleep(1000) /// we dpn't want to overheat :P
    /***
    * interrestingly CAS doesn't work, because of
    * some weird Apple memory scheme.
    * OSAtomicCompareAndSwapPtr: doesn't work
    */
    var val:UInt8 = 0
    repeat {
    usleep(1)
    OSMemoryBarrier()
    val = bval!.pointee!.load(as:UInt8.self)
    }while ( val == 1 || val == 2)
    OSMemoryBarrier()
    bval!.pointee!.storeBytes(of:1,as: UInt8.self)
    repeat {
    usleep(1)
    OSMemoryBarrier()
    val = bval!.pointee!.load(as:UInt8.self)
    }while ( val == 2)
    OSMemoryBarrier()
    bval!.pointee!.storeBytes(of:2,as: UInt8.self)
    print("acquired")
    /// payLoad
    OSMemoryBarrier()
    bval!.pointee!.storeBytes(of:0,as: UInt8.self)
    print("releazed\n")
    --

    7-77-777
    Evil Sinner!
    to weak you should be meek, and you should brainfuck stronger https://github.com/rofl0r/chaos-pp

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Wed Oct 6 20:01:31 2021
    On 10/6/2021 7:45 PM, Branimir Maksimovic wrote:
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/6/2021 7:17 PM, Branimir Maksimovic wrote:
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote: >>>> ideal. A wait-free fast-path is even better!

    Then, you have to think what to do, when there is is nothing
    to do :P


    When the fast-path fails, we can choose to try to wait. Usually on a
    Futex or Eventcount. The main idea is under periods of load, when the
    structure is not empty, we can fly along lock/wait-free paths.

    iWhat you think about this code:
    while(true){
    usleep(1000) /// we dpn't want to overheat :P
    /***
    * interrestingly CAS doesn't work, because of
    * some weird Apple memory scheme.
    * OSAtomicCompareAndSwapPtr: doesn't work
    */
    var val:UInt8 = 0
    repeat {
    usleep(1)
    OSMemoryBarrier()
    val = bval!.pointee!.load(as:UInt8.self)
    }while ( val == 1 || val == 2)
    OSMemoryBarrier()
    bval!.pointee!.storeBytes(of:1,as: UInt8.self)
    repeat {
    usleep(1)
    OSMemoryBarrier()
    val = bval!.pointee!.load(as:UInt8.self)
    }while ( val == 2)
    OSMemoryBarrier()
    bval!.pointee!.storeBytes(of:2,as: UInt8.self)
    print("acquired")
    /// payLoad
    OSMemoryBarrier()
    bval!.pointee!.storeBytes(of:0,as: UInt8.self)
    print("releazed\n")




    I need to really examine it, but it kind of reminds me of a way to load
    things up in some sort of odd sequence lock. There is a shitload of
    membars in there. Heck, is OSMemoryBarrier akin to a #StoreLoad |
    #LoadStore | #Load#Load | #Store#Store on the SPARC, in other words seq
    order? Humm... I cannot believe that CAS does not work! What does std::atomic<T>::compare_exchange_weak() with a membar of std::memory_order_relaxed disassemble into?

    Btw, a seqlock is:

    https://en.wikipedia.org/wiki/Seqlock

    If OSMemoryBarrier is seq_order this this should go really slow.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Thu Oct 7 03:24:57 2021
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    order? Humm... I cannot believe that CAS does not work! What does std::atomic<T>::compare_exchange_weak() with a membar of std::memory_order_relaxed disassemble into?
    Problem is OS, how it maps memory. I didn't figured out why,
    but simply value is not readed, that is, if I do it in assembler,
    it would probably work, but I have tried to do it in HLL :P
    This is M1, but I think it is more related to OS...
    Haven't tried C++ though :P

    --

    7-77-777
    Evil Sinner!
    to weak you should be meek, and you should brainfuck stronger https://github.com/rofl0r/chaos-pp

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Thu Oct 7 08:37:07 2021
    Am 07.10.2021 um 02:19 schrieb Chris M. Thomasson:
    On 10/2/2021 1:57 AM, Bonita Montero wrote:
    Am 02.10.2021 um 10:36 schrieb Chris M. Thomasson:

    Why do you make me want to cough when I read some of your comments?
    The idea is to try to minimize slow-paths... Think about it! Damn
    it... ;^o

    The idea of lock-free algorithms is not to have slow paths at all.

    Why not? You have a very narrow view. A pure lock-free fast-path is
    ideal. A wait-free fast-path is even better!

    That's not a narrow view but it is how it's defined.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Thu Oct 7 08:36:19 2021
    Am 06.10.2021 um 21:22 schrieb Chris M. Thomasson:
    On 10/4/2021 10:13 PM, Bonita Montero wrote:
    Am 04.10.2021 um 20:31 schrieb Chris M. Thomasson:
    On 10/2/2021 1:27 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:32 schrieb Chris M. Thomasson:
    On 10/2/2021 12:30 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:20 schrieb Chris M. Thomasson:

    A mutex isn't a lock-free structure because is _also_ has a
    slow path.

    It can have a very nice fast-path... Have you ever created one?

    That's not what we're talking about.


    I am talking about the nice fast-path being totally lock/wait-free.
    It can! Think about it some more.

    Lock-free is when you only have a fast path - and no slow path.

    Why not combine the two? Ahhh, the futex, or eventcount.

    Then it's not lock-free anymore.

    However, it has lock-free fast-paths. That is a huge advantage!

    Then you could call every mutex lock-free. But no one does that.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Thu Oct 7 00:31:54 2021
    On 10/6/2021 11:36 PM, Bonita Montero wrote:
    Am 06.10.2021 um 21:22 schrieb Chris M. Thomasson:
    On 10/4/2021 10:13 PM, Bonita Montero wrote:
    Am 04.10.2021 um 20:31 schrieb Chris M. Thomasson:
    On 10/2/2021 1:27 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:32 schrieb Chris M. Thomasson:
    On 10/2/2021 12:30 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:20 schrieb Chris M. Thomasson:

    A mutex isn't a lock-free structure because is _also_ has a
    slow path.

    It can have a very nice fast-path... Have you ever created one? >>>>>>>
    That's not what we're talking about.


    I am talking about the nice fast-path being totally
    lock/wait-free. It can! Think about it some more.

    Lock-free is when you only have a fast path - and no slow path.

    Why not combine the two? Ahhh, the futex, or eventcount.

    Then it's not lock-free anymore.

    However, it has lock-free fast-paths. That is a huge advantage!

    Then you could call every mutex lock-free. But no one does that.


    You can call access to an unlocked mutex a fast-path. It sounds like you
    have never heard of a benaphore before. Too bad.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Thu Oct 7 01:15:07 2021
    On 10/6/2021 11:37 PM, Bonita Montero wrote:
    Am 07.10.2021 um 02:19 schrieb Chris M. Thomasson:
    On 10/2/2021 1:57 AM, Bonita Montero wrote:
    Am 02.10.2021 um 10:36 schrieb Chris M. Thomasson:

    Why do you make me want to cough when I read some of your comments?
    The idea is to try to minimize slow-paths... Think about it! Damn
    it... ;^o

    The idea of lock-free algorithms is not to have slow paths at all.

    Why not? You have a very narrow view. A pure lock-free fast-path is
    ideal. A wait-free fast-path is even better!

    That's not a narrow view but it is how it's defined.

    Yeah... Think outside of the box and use a lock/wait-free algorihtm for
    a fast-path, and use a Futex or Eventcount for the slow-path.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ian Collins@21:1/5 to Chris M. Thomasson on Thu Oct 7 22:26:18 2021
    On 07/10/2021 14:11, Chris M. Thomasson wrote:

    No problem. Fwiw, here is a new test animation I made:

    https://youtu.be/nPR4xK-5i4I

    https://www.youtube.com/watch?v=nPR4xK-5i4I

    Both links work for me. How many work for you? Just wondering.

    Cool!

    --
    Ian.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Thu Oct 7 12:16:13 2021
    Am 07.10.2021 um 10:15 schrieb Chris M. Thomasson:

    That's not a narrow view but it is how it's defined.

    Yeah... Think outside of the box and use a lock/wait-free algorihtm
    for a fast-path, and use a Futex or Eventcount for the slow-path.

    Lock-free algorithms don't have a slow path.
    That's while they don't lock and you've to poll them.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Thu Oct 7 12:15:19 2021
    Am 07.10.2021 um 09:31 schrieb Chris M. Thomasson:
    On 10/6/2021 11:36 PM, Bonita Montero wrote:
    Am 06.10.2021 um 21:22 schrieb Chris M. Thomasson:
    On 10/4/2021 10:13 PM, Bonita Montero wrote:
    Am 04.10.2021 um 20:31 schrieb Chris M. Thomasson:
    On 10/2/2021 1:27 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:32 schrieb Chris M. Thomasson:
    On 10/2/2021 12:30 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:20 schrieb Chris M. Thomasson:

    A mutex isn't a lock-free structure because is _also_ has a >>>>>>>>>> slow path.

    It can have a very nice fast-path... Have you ever created one? >>>>>>>>
    That's not what we're talking about.


    I am talking about the nice fast-path being totally
    lock/wait-free. It can! Think about it some more.

    Lock-free is when you only have a fast path - and no slow path.

    Why not combine the two? Ahhh, the futex, or eventcount.

    Then it's not lock-free anymore.

    However, it has lock-free fast-paths. That is a huge advantage!

    Then you could call every mutex lock-free. But no one does that.


    You can call access to an unlocked mutex a fast-path.

    Yes, but because of that fast path a mutex isn't lock-free.
    You say that everything having a fast path could be called lock-free.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Thu Oct 7 12:21:13 2021
    On 10/7/2021 3:15 AM, Bonita Montero wrote:
    Am 07.10.2021 um 09:31 schrieb Chris M. Thomasson:
    On 10/6/2021 11:36 PM, Bonita Montero wrote:
    Am 06.10.2021 um 21:22 schrieb Chris M. Thomasson:
    On 10/4/2021 10:13 PM, Bonita Montero wrote:
    Am 04.10.2021 um 20:31 schrieb Chris M. Thomasson:
    On 10/2/2021 1:27 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:32 schrieb Chris M. Thomasson:
    On 10/2/2021 12:30 AM, Bonita Montero wrote:
    Am 02.10.2021 um 09:20 schrieb Chris M. Thomasson:

    A mutex isn't a lock-free structure because is _also_ has a >>>>>>>>>>> slow path.

    It can have a very nice fast-path... Have you ever created one? >>>>>>>>>
    That's not what we're talking about.


    I am talking about the nice fast-path being totally
    lock/wait-free. It can! Think about it some more.

    Lock-free is when you only have a fast path - and no slow path.

    Why not combine the two? Ahhh, the futex, or eventcount.

    Then it's not lock-free anymore.

    However, it has lock-free fast-paths. That is a huge advantage!

    Then you could call every mutex lock-free. But no one does that.


    You can call access to an unlocked mutex a fast-path.

    Yes, but because of that fast path a mutex isn't lock-free.
    You say that everything having a fast path could be called lock-free.

    I am saying the fast-path is lock/wait-free. Then there is the
    slow-path... A completely different story. A futex and eventcount are
    used to allow the data-structure to be waited on. A futex is much lower
    level than eventcount. An eventcount is kind of akin to a condvar for lock/wait-free algorithms. A futex can be used to build an eventcount.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Thu Oct 7 12:26:17 2021
    On 10/7/2021 3:16 AM, Bonita Montero wrote:
    Am 07.10.2021 um 10:15 schrieb Chris M. Thomasson:

    That's not a narrow view but it is how it's defined.

    Yeah... Think outside of the box and use a lock/wait-free algorihtm
    for  a fast-path, and use a Futex or Eventcount for the slow-path.

    Lock-free algorithms don't have a slow path.
    That's while they don't lock and you've to poll them.

    Why poll them? Add a slow-path using futex or eventcount... Is seems
    that you are having a hard time understanding this... This keeps the
    fast-path for periods of load, when sheer performance matters. Under
    load, the data-structure is much more likely to hit fast-paths, and reap
    the benefits from lock/wait free algorithms. Got it?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Thu Oct 7 20:14:56 2021
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    Yes, but because of that fast path a mutex isn't lock-free.
    You say that everything having a fast path could be called lock-free.

    I am saying the fast-path is lock/wait-free. Then there is the
    slow-path... A completely different story. A futex and eventcount are
    used to allow the data-structure to be waited on. A futex is much lower
    level than eventcount. An eventcount is kind of akin to a condvar for lock/wait-free algorithms. A futex can be used to build an eventcount.
    Well only thing you can do is sleep not to overheat :P

    --

    7-77-777
    Evil Sinner!
    with software, you repeat same experiment, expecting different results...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Thu Oct 7 20:16:15 2021
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/7/2021 3:16 AM, Bonita Montero wrote:
    Am 07.10.2021 um 10:15 schrieb Chris M. Thomasson:

    That's not a narrow view but it is how it's defined.

    Yeah... Think outside of the box and use a lock/wait-free algorihtm
    for  a fast-path, and use a Futex or Eventcount for the slow-path.

    Lock-free algorithms don't have a slow path.
    That's while they don't lock and you've to poll them.

    Why poll them? Add a slow-path using futex or eventcount... Is seems
    that you are having a hard time understanding this... This keeps the fast-path for periods of load, when sheer performance matters. Under
    load, the data-structure is much more likely to hit fast-paths, and reap
    the benefits from lock/wait free algorithms. Got it?
    Yeah, problem is when you don't have something usefull to do :P


    --

    7-77-777
    Evil Sinner!
    with software, you repeat same experiment, expecting different results...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Thu Oct 7 14:27:46 2021
    On 10/7/2021 1:16 PM, Branimir Maksimovic wrote:
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/7/2021 3:16 AM, Bonita Montero wrote:
    Am 07.10.2021 um 10:15 schrieb Chris M. Thomasson:

    That's not a narrow view but it is how it's defined.

    Yeah... Think outside of the box and use a lock/wait-free algorihtm
    for  a fast-path, and use a Futex or Eventcount for the slow-path.

    Lock-free algorithms don't have a slow path.
    That's while they don't lock and you've to poll them.

    Why poll them? Add a slow-path using futex or eventcount... Is seems
    that you are having a hard time understanding this... This keeps the
    fast-path for periods of load, when sheer performance matters. Under
    load, the data-structure is much more likely to hit fast-paths, and reap
    the benefits from lock/wait free algorithms. Got it?
    Yeah, problem is when you don't have something usefull to do :P



    Indeed. There is a funny way to use try_lock to try to gain this sort of pattern... Iirc, it went something like:
    __________________________
    void lock()
    {
    while (! try_lock())
    {
    if (! try_to_do_something_else())
    {
    lock();
    break;
    }
    }
    }
    __________________________

    So, if something else was done, we can try_lock again. Iirc, I even put
    a limit on how many times try_lock() can be called. Akin to an adaptive
    mutex, except instead of spinning, we see if something else can be done.

    It does work in certain scenarios and/or setups...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Thu Oct 7 23:27:16 2021
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/7/2021 1:16 PM, Branimir Maksimovic wrote:
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/7/2021 3:16 AM, Bonita Montero wrote:
    Am 07.10.2021 um 10:15 schrieb Chris M. Thomasson:

    That's not a narrow view but it is how it's defined.

    Yeah... Think outside of the box and use a lock/wait-free algorihtm for  >>>>> a fast-path, and use a Futex or Eventcount for the slow-path.

    Lock-free algorithms don't have a slow path. That's while they don't lock >>>> and you've to poll them.

    Why poll them? Add a slow-path using futex or eventcount... Is seems that >>> you are having a hard time understanding this... This keeps the fast-path >>> for periods of load, when sheer performance matters. Under load, the
    data-structure is much more likely to hit fast-paths, and reap the benefits >>> from lock/wait free algorithms. Got it?
    Yeah, problem is when you don't have something usefull to do :P



    Indeed. There is a funny way to use try_lock to try to gain this sort of pattern... Iirc, it went something like: __________________________ void lock() { while (! try_lock()) { if (! try_to_do_something_else()) { lock(); break; } } } __________________________

    So, if something else was done, we can try_lock again. Iirc, I even put a limit on how many times try_lock() can be called. Akin to an adaptive mutex, except instead of spinning, we see if something else can be done.

    It does work in certain scenarios and/or setups...
    You have *understanding* :P
    Thanks!

    --

    7-77-777
    Evil Sinner!
    with software, you repeat same experiment, expecting different results...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Fri Oct 8 07:53:16 2021
    Am 07.10.2021 um 21:26 schrieb Chris M. Thomasson:
    On 10/7/2021 3:16 AM, Bonita Montero wrote:
    Am 07.10.2021 um 10:15 schrieb Chris M. Thomasson:

    That's not a narrow view but it is how it's defined.

    Yeah... Think outside of the box and use a lock/wait-free algorihtm
    for  a fast-path, and use a Futex or Eventcount for the slow-path.

    Lock-free algorithms don't have a slow path.
    That's while they don't lock and you've to poll them.

    Why poll them? ...

    Because they are lock-free.

    Add a slow-path using futex or eventcount...

    Then they aren't lock-free anymore.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Fri Oct 8 07:52:17 2021
    Am 07.10.2021 um 21:21 schrieb Chris M. Thomasson:

    I am saying the fast-path is lock/wait-free.

    No one calls sth. with a fast path and a slow path lock-free.
    Lock-free is _only_ without a slow path. Idiot !

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Oct 8 12:56:52 2021
    On 10/7/2021 10:52 PM, Bonita Montero wrote:
    Am 07.10.2021 um 21:21 schrieb Chris M. Thomasson:

    I am saying the fast-path is lock/wait-free.

    No one calls sth. with a fast path and a slow path lock-free.
    Lock-free is _only_ without a slow path. Idiot !

    Sigh. Never mind. I am casting my pearls before, well, whatever.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Fri Oct 8 13:13:57 2021
    On 10/6/2021 8:24 PM, Branimir Maksimovic wrote:
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    order? Humm... I cannot believe that CAS does not work! What does
    std::atomic<T>::compare_exchange_weak() with a membar of
    std::memory_order_relaxed disassemble into?
    Problem is OS, how it maps memory. I didn't figured out why,
    but simply value is not readed, that is, if I do it in assembler,
    it would probably work, but I have tried to do it in HLL :P
    This is M1, but I think it is more related to OS...
    Haven't tried C++ though :P


    Try to get a disassembly of std::atomic<T>::compare_exchange_weak() on
    your system. Start with an unsigned int. I am interested!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Fri Oct 8 13:05:23 2021
    On 10/3/2021 9:44 PM, Branimir Maksimovic wrote:
    On 2021-10-03, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    No problem. Glad you can see them. Also, fwiw, here is my vector field
    rendered in real time using a GLSL shader:

    https://www.shadertoy.com/view/MdcyRs

    You can press and drag a point around in the animation to create an attractor
    in the field. Also, he is my field using WebGL:

    http://fractallife247.com/test/webgl/

    Does it work for you? Thanks.
    Both work on Safari, thanks.


    I am glad they work for you! Thanks for taking the time to give them a
    go. Now, I am wondering if the following program of mine works on Safari
    on your end. Iirc, it works on Safari for windows... ;^)

    Its a highly experimental field based DLA algorihtm I created. Let it
    run for around a half a minute or so. Then try to click around in the
    field, and see what happens... A click should create a new attractor and
    start influencing the field in real time. Keep in mind that the
    particles are following field lines instead of using random walks. This
    is different than "traditional" DLA:

    http://fractallife247.com/fdla/

    Fwiw, here is a decent description of DLA:

    https://en.wikipedia.org/wiki/Diffusion-limited_aggregation

    Thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Fri Oct 8 12:53:33 2021
    On 10/7/2021 10:53 PM, Bonita Montero wrote:
    Am 07.10.2021 um 21:26 schrieb Chris M. Thomasson:
    On 10/7/2021 3:16 AM, Bonita Montero wrote:
    Am 07.10.2021 um 10:15 schrieb Chris M. Thomasson:

    That's not a narrow view but it is how it's defined.

    Yeah... Think outside of the box and use a lock/wait-free algorihtm
    for  a fast-path, and use a Futex or Eventcount for the slow-path.

    Lock-free algorithms don't have a slow path.
    That's while they don't lock and you've to poll them.

    Why poll them? ...

    Because they are lock-free.

    Sigh... Polling is inefficient waiting, in a sense. Anyway...



    Add a slow-path using futex or eventcount...

    Then they aren't lock-free anymore.


    Oh well. I tried everybody. She does not seem to get it.

    Shit happens.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Ian Collins on Fri Oct 8 14:07:14 2021
    On 10/7/2021 2:26 AM, Ian Collins wrote:
    On 07/10/2021 14:11, Chris M. Thomasson wrote:

    No problem. Fwiw, here is a new test animation I made:

    https://youtu.be/nPR4xK-5i4I

    https://www.youtube.com/watch?v=nPR4xK-5i4I

    Both links work for me. How many work for you? Just wondering.

    Cool!


    Thanks Ian! Fwiw, when you get some time to kill, check this older image
    out:

    http://siggrapharts.ning.com/photo/heavenly-visions

    Its from one of my experimental IFS's. One of my friends wrote about
    some of its inner workings here:

    http://paulbourke.net/fractals/multijulia/

    I have it coded up in C++. :^)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Chris M. Thomasson on Fri Oct 8 15:24:27 2021
    On 10/7/2021 2:27 PM, Chris M. Thomasson wrote:
    On 10/7/2021 1:16 PM, Branimir Maksimovic wrote:
    On 2021-10-07, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/7/2021 3:16 AM, Bonita Montero wrote:
    Am 07.10.2021 um 10:15 schrieb Chris M. Thomasson:

    That's not a narrow view but it is how it's defined.

    Yeah... Think outside of the box and use a lock/wait-free algorihtm
    for  a fast-path, and use a Futex or Eventcount for the slow-path.

    Lock-free algorithms don't have a slow path.
    That's while they don't lock and you've to poll them.

    Why poll them? Add a slow-path using futex or eventcount... Is seems
    that you are having a hard time understanding this... This keeps the
    fast-path for periods of load, when sheer performance matters. Under
    load, the data-structure is much more likely to hit fast-paths, and reap >>> the benefits from lock/wait free algorithms. Got it?
    Yeah, problem is when you don't have something usefull to do :P



    Indeed. There is a funny way to use try_lock to try to gain this sort of pattern... Iirc, it went something like:
    __________________________
    void lock()
    {
       while (! try_lock())
       {
          if (! try_to_do_something_else())
          {
              lock();
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    Oh crap. I did not mean to imply recursion here! Let me fix that: __________________________
    void my_custom_lock()
    {
    while (! try_lock())
    {
    if (! try_to_do_something_else())
    {
    lock();
    break;
    }
    }
    }
    __________________________

    There, now there is no possibility of recursion in my pseudo-code. Sorry
    for any confusion! Ouch! ;^o




              break;
          }
       }
    }
    __________________________

    So, if something else was done, we can try_lock again. Iirc, I even put
    a limit on how many times try_lock() can be called. Akin to an adaptive mutex, except instead of spinning, we see if something else can be done.

    It does work in certain scenarios and/or setups...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 9 09:38:00 2021
    Am 07.10.2021 um 03:22 schrieb Chris M. Thomasson:
    On 10/2/2021 4:07 AM, Bonita Montero wrote:
    Am 02.10.2021 um 13:06 schrieb Bonita Montero:
    Am 02.10.2021 um 12:03 schrieb Chris M. Thomasson:

    Lock-free stacks are used for pooling or handling back resoruces to an >>>>> owning thread.

    Really, is that their only use? ..

    Yes.

    Or more precisely: pracitcally yes. Because other uses aren't
    practicable because of the drawbacks of lock-free algorithms.



    think outside of the box.

    Any algorihm having a slow path isn't
    lock free because the slow path locks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Sat Oct 9 07:29:19 2021
    On 2021-10-08, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/3/2021 9:44 PM, Branimir Maksimovic wrote:
    On 2021-10-03, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    No problem. Glad you can see them. Also, fwiw, here is my vector field
    rendered in real time using a GLSL shader:

    https://www.shadertoy.com/view/MdcyRs

    You can press and drag a point around in the animation to create an attractor
    in the field. Also, he is my field using WebGL:

    http://fractallife247.com/test/webgl/

    Does it work for you? Thanks.
    Both work on Safari, thanks.


    I am glad they work for you! Thanks for taking the time to give them a
    go. Now, I am wondering if the following program of mine works on Safari
    on your end. Iirc, it works on Safari for windows... ;^)

    Its a highly experimental field based DLA algorihtm I created. Let it
    run for around a half a minute or so. Then try to click around in the
    field, and see what happens... A click should create a new attractor and start influencing the field in real time. Keep in mind that the
    particles are following field lines instead of using random walks. This
    is different than "traditional" DLA:

    http://fractallife247.com/fdla/

    Fwiw, here is a decent description of DLA:

    https://en.wikipedia.org/wiki/Diffusion-limited_aggregation

    Thanks.
    Works! thanks!

    --

    7-77-777
    Evil Sinner!
    with software, you repeat same experiment, expecting different results...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Sat Oct 9 13:13:56 2021
    On 10/9/2021 12:59 PM, Bonita Montero wrote:
    So allowing a fast and a slow path gives the best of both worlds.

    Am I talking to a complete idiot here ?

    We're not discussing what's the best while synchronizing threads
    but what's lock-free and what's not. And having a slow path makes
    an algorithm not lock-free.

    Read the WP-article: https://en.wikipedia.org/wiki/Non-blocking_algorithm : "In computer science, an algorithm is called non-blocking
     if failure or suspension of any thread cannot cause failure
     _or suspension of another thread_".


    You think lock-free is crap. You wrote such things. So, whatever Bonita.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Sat Oct 9 12:29:55 2021
    On 10/9/2021 12:38 AM, Bonita Montero wrote:
    Am 07.10.2021 um 03:22 schrieb Chris M. Thomasson:
    On 10/2/2021 4:07 AM, Bonita Montero wrote:
    Am 02.10.2021 um 13:06 schrieb Bonita Montero:
    Am 02.10.2021 um 12:03 schrieb Chris M. Thomasson:

    Lock-free stacks are used for pooling or handling back resoruces
    to an
    owning thread.

    Really, is that their only use? ..

    Yes.

    Or more precisely: pracitcally yes. Because other uses aren't
    practicable because of the drawbacks of lock-free algorithms.



    think outside of the box.

    Any algorihm having a slow path isn't
    lock free because the slow path locks.

    One can even choose to follow the slow-path or not. It would be in the
    try_* variety of functions... ;^)

    So allowing a fast and a slow path gives the best of both worlds.

    :^)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sat Oct 9 21:59:08 2021
    So allowing a fast and a slow path gives the best of both worlds.

    Am I talking to a complete idiot here ?

    We're not discussing what's the best while synchronizing threads
    but what's lock-free and what's not. And having a slow path makes
    an algorithm not lock-free.

    Read the WP-article: https://en.wikipedia.org/wiki/Non-blocking_algorithm :
    "In computer science, an algorithm is called non-blocking
    if failure or suspension of any thread cannot cause failure
    _or suspension of another thread_".

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Sat Oct 9 19:55:17 2021
    On 10/9/2021 12:29 AM, Branimir Maksimovic wrote:
    On 2021-10-08, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    On 10/3/2021 9:44 PM, Branimir Maksimovic wrote:
    On 2021-10-03, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote: >>>> No problem. Glad you can see them. Also, fwiw, here is my vector field >>>> rendered in real time using a GLSL shader:

    https://www.shadertoy.com/view/MdcyRs

    You can press and drag a point around in the animation to create an attractor
    in the field. Also, he is my field using WebGL:

    http://fractallife247.com/test/webgl/

    Does it work for you? Thanks.
    Both work on Safari, thanks.


    I am glad they work for you! Thanks for taking the time to give them a
    go. Now, I am wondering if the following program of mine works on Safari
    on your end. Iirc, it works on Safari for windows... ;^)

    Its a highly experimental field based DLA algorihtm I created. Let it
    run for around a half a minute or so. Then try to click around in the
    field, and see what happens... A click should create a new attractor and
    start influencing the field in real time. Keep in mind that the
    particles are following field lines instead of using random walks. This
    is different than "traditional" DLA:

    http://fractallife247.com/fdla/

    Fwiw, here is a decent description of DLA:

    https://en.wikipedia.org/wiki/Diffusion-limited_aggregation

    Thanks.
    Works! thanks!


    Perfect! All right. Cool. Thanks again. Btw, I made a new test animation
    in 3d:

    https://www.youtube.com/watch?v=2gznap7wLeQ

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Bonita Montero on Sat Oct 9 22:04:06 2021
    On 10/9/2021 9:42 PM, Bonita Montero wrote:
    Am 09.10.2021 um 22:13 schrieb Chris M. Thomasson:
    On 10/9/2021 12:59 PM, Bonita Montero wrote:
    So allowing a fast and a slow path gives the best of both worlds.

    Am I talking to a complete idiot here ?

    We're not discussing what's the best while synchronizing threads
    but what's lock-free and what's not. And having a slow path makes
    an algorithm not lock-free.

    Read the WP-article:
    https://en.wikipedia.org/wiki/Non-blocking_algorithm :
    "In computer science, an algorithm is called non-blocking
      if failure or suspension of any thread cannot cause failure
      _or suspension of another thread_".


    You think lock-free is crap. ...

    Everything lock-free except from lock-free stacks is crap.


    Whatever you say man! ;^o

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Sun Oct 10 06:42:14 2021
    Am 09.10.2021 um 22:13 schrieb Chris M. Thomasson:
    On 10/9/2021 12:59 PM, Bonita Montero wrote:
    So allowing a fast and a slow path gives the best of both worlds.

    Am I talking to a complete idiot here ?

    We're not discussing what's the best while synchronizing threads
    but what's lock-free and what's not. And having a slow path makes
    an algorithm not lock-free.

    Read the WP-article:
    https://en.wikipedia.org/wiki/Non-blocking_algorithm :
    "In computer science, an algorithm is called non-blocking
      if failure or suspension of any thread cannot cause failure
      _or suspension of another thread_".


    You think lock-free is crap. ...

    Everything lock-free except from lock-free stacks is crap.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Chris M. Thomasson on Mon Oct 11 05:21:49 2021
    On 2021-10-10, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    Thanks.
    Works! thanks!


    Perfect! All right. Cool. Thanks again. Btw, I made a new test animation
    in 3d:

    https://www.youtube.com/watch?v=2gznap7wLeQ
    Nice work of art, show me more !
    Thanks!

    --

    7-77-777
    Evil Sinner!
    with software, you repeat same experiment, expecting different results...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Branimir Maksimovic on Thu Oct 28 13:49:48 2021
    On 10/10/2021 10:21 PM, Branimir Maksimovic wrote:
    On 2021-10-10, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
    Thanks.
    Works! thanks!


    Perfect! All right. Cool. Thanks again. Btw, I made a new test animation
    in 3d:

    https://www.youtube.com/watch?v=2gznap7wLeQ
    Nice work of art, show me more !
    Thanks!


    Fwiw, Here is a new, highly experimental animation of one of my
    biomorphic fractal algorithms using rings comprised of tori. Next
    version will have some music! ;^)

    Well, what do you think?

    https://youtu.be/3abgNkpIY98

    https://www.youtube.com/watch?v=3abgNkpIY98

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From danielaparker@gmail.com@21:1/5 to Chris M. Thomasson on Thu Oct 28 20:29:56 2021
    On Thursday, October 28, 2021 at 4:50:05 PM UTC-4, Chris M. Thomasson wrote:

    Fwiw, Here is a new, highly experimental animation of one of my
    biomorphic fractal algorithms using rings comprised of tori. Next
    version will have some music! ;^)

    Well, what do you think?

    https://youtu.be/3abgNkpIY98

    https://www.youtube.com/watch?v=3abgNkpIY98

    Pretty cool!

    Daniel

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