Changeset 07033ce


Ignore:
Timestamp:
Jun 14, 2021, 4:03:50 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
1f05c83, 6f8c46d, cb5c392
Parents:
a8b0618
Message:

Even more work on removing any possible integer overflow in fast lock test

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/locks.hfa

    ra8b0618 r07033ce  
    2121#include "bits/weakso_locks.hfa"
    2222#include "containers/queueLockFree.hfa"
    23 
     23#include "limits.hfa"
    2424#include "thread.hfa"
    2525
     
    8585        bool tryP(BinaryBenaphore & this) {
    8686                ssize_t c = this.counter;
     87                /* paranoid */ verify( c > MIN );
    8788                return (c >= 1) && __atomic_compare_exchange_n(&this.counter, &c, c-1, false, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);
    8889        }
     
    9293                ssize_t c = 0;
    9394                for () {
     95                        /* paranoid */ verify( this.counter < MAX );
    9496                        if (__atomic_compare_exchange_n(&this.counter, &c, c+1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    9597                                if (c == 0) return true;
  • tests/unified_locking/fast.cfa

    ra8b0618 r07033ce  
    2222uint32_t cs() {
    2323        $thread * me = active_thread();
    24         uint32_t value = (uint32_t)me;
     24        uint32_t value;
    2525        lock(mo.l);
    2626        {
     
    2828                mo.id = me;
    2929                yield(random(5));
     30                value = ((uint32_t)random()) ^ ((uint32_t)me);
    3031                if(mo.id != me) sout | "Intruder!";
    3132                mo.sum = tsum + value;
Note: See TracChangeset for help on using the changeset viewer.