Esempio n. 1
0
/* =============================================================================
 * process
 * =============================================================================
 */
static void
process ()
{
    heap_t* workHeapPtr = global_workHeapPtr;
    mesh_t* meshPtr = global_meshPtr;
    region_t* regionPtr;
    long totalNumAdded = 0;
    long numProcess = 0;

    regionPtr = PREGION_ALLOC();
    assert(regionPtr);

    while (1) {

        element_t* elementPtr;

        __transaction_atomic {
            elementPtr = (element_t*)TMHEAP_REMOVE(workHeapPtr);
        }

        if (elementPtr == NULL) {
            break;
        }

        bool_t isGarbage;
        __transaction_atomic {
            isGarbage = TMELEMENT_ISGARBAGE(elementPtr);
        }
        if (isGarbage) {
            /*
             * Handle delayed deallocation
             */
            TMELEMENT_FREE(elementPtr);
            continue;
        }

        long numAdded;
        //[wer210] changed the control flow to get rid of self-abort
        bool_t success = TRUE;
        while (1) {
            __transaction_atomic {
                // TM_SAFE: PVECTOR_CLEAR (regionPtr->badVectorPtr);
                PREGION_CLEARBAD(regionPtr);
                //[wer210] problematic function!
                numAdded = TMREGION_REFINE(regionPtr, elementPtr, meshPtr, &success);
                if (success) break;
                else __transaction_cancel;
            }
        }

        __transaction_atomic {
            TMELEMENT_SETISREFERENCED(elementPtr, FALSE);
            isGarbage = TMELEMENT_ISGARBAGE(elementPtr);
        }
        if (isGarbage) {
            /*
             * Handle delayed deallocation
             */
            TMELEMENT_FREE(elementPtr);
        }

        totalNumAdded += numAdded;

        __transaction_atomic {
            TMREGION_TRANSFERBAD(regionPtr, workHeapPtr);
        }

        numProcess++;

    }

    __transaction_atomic {
        TM_SHARED_WRITE(global_totalNumAdded,
        TM_SHARED_READ(global_totalNumAdded) + totalNumAdded);
        TM_SHARED_WRITE(global_numProcess,
        TM_SHARED_READ(global_numProcess) + numProcess);
    }

    PREGION_FREE(regionPtr);
}
Esempio n. 2
0
/* =============================================================================
 * process
 * =============================================================================
 */
void
process ()
{
    TM_THREAD_ENTER();

    heap_t* workHeapPtr = global_workHeapPtr;
    mesh_t* meshPtr = global_meshPtr;
    region_t* regionPtr;
    long totalNumAdded = 0;
    long numProcess = 0;

    regionPtr = PREGION_ALLOC();
    assert(regionPtr);

    while (1) {

        element_t* elementPtr;

        AL_LOCK(0);
        TM_BEGIN(0);
        elementPtr = TMHEAP_REMOVE(workHeapPtr);
        TM_END();
        if (elementPtr == NULL) {
            break;
        }

        bool_t isGarbage;
        AL_LOCK(0);
        TM_BEGIN(1);
        isGarbage = TMELEMENT_ISGARBAGE(elementPtr);
        TM_END();
        if (isGarbage) {
            /*
             * Handle delayed deallocation
             */
            PELEMENT_FREE(elementPtr);
            continue;
        }

        long numAdded;

        AL_LOCK(0);
        TM_BEGIN(2);
        PREGION_CLEARBAD(regionPtr);
        numAdded = TMREGION_REFINE(regionPtr, elementPtr, meshPtr);
        TM_END();

        AL_LOCK(0);
        TM_BEGIN(3);
        TMELEMENT_SETISREFERENCED(elementPtr, FALSE);
        isGarbage = TMELEMENT_ISGARBAGE(elementPtr);
        TM_END();
        if (isGarbage) {
            /*
             * Handle delayed deallocation
             */
            PELEMENT_FREE(elementPtr);
        }

        totalNumAdded += numAdded;

        AL_LOCK(0);
        TM_BEGIN(4);
        TMREGION_TRANSFERBAD(regionPtr, workHeapPtr);
        TM_END();

        numProcess++;

    }

    AL_LOCK(0);
    TM_BEGIN(5);
    TM_SHARED_WRITE(global_totalNumAdded,
                    TM_SHARED_READ(global_totalNumAdded) + totalNumAdded);
    TM_SHARED_WRITE(global_numProcess,
                    TM_SHARED_READ(global_numProcess) + numProcess);
    TM_END();

    PREGION_FREE(regionPtr);

    TM_THREAD_EXIT();
}
Esempio n. 3
0
/* =============================================================================
 * process
 * =============================================================================
 */
void
process ()
{
    TM_THREAD_ENTER();

    heap_t* workHeapPtr = global_workHeapPtr;
    mesh_t* meshPtr = global_meshPtr;
    region_t* regionPtr;
    long totalNumAdded = 0;
    long numProcess = 0;

    regionPtr = PREGION_ALLOC();
    assert(regionPtr);

    while (1) {

        element_t* elementPtr;

        __transaction_atomic {
            elementPtr = TMHEAP_REMOVE(workHeapPtr);
        }
        if (elementPtr == NULL) {
            break;
        }

        bool_t isGarbage;
        __transaction_atomic {
            isGarbage = TMELEMENT_ISGARBAGE(elementPtr);
        }
        if (isGarbage) {
            /*
             * Handle delayed deallocation
             */
            PELEMENT_FREE(elementPtr);
            continue;
        }

        long numAdded;

        __transaction_atomic {
            PREGION_CLEARBAD(regionPtr);
            numAdded = TMREGION_REFINE(regionPtr, elementPtr, meshPtr);
        }

        __transaction_atomic {
            TMELEMENT_SETISREFERENCED(elementPtr, FALSE);
            isGarbage = TMELEMENT_ISGARBAGE(elementPtr);
        }
        if (isGarbage) {
            /*
             * Handle delayed deallocation
             */
            PELEMENT_FREE(elementPtr);
        }

        totalNumAdded += numAdded;

        __transaction_atomic {
            TMREGION_TRANSFERBAD(regionPtr, workHeapPtr);
        }

        numProcess++;

    }

    __transaction_atomic {
        global_totalNumAdded = global_totalNumAdded + totalNumAdded;
        global_numProcess = global_numProcess + numProcess;
    }

    PREGION_FREE(regionPtr);

    TM_THREAD_EXIT();
}