inline static void *Execute(void* Arg) {
    MSQueueThreadState *th_state;
    long i;
    long id = (long) Arg;
    long rnum;
    volatile long j;

    th_state = getAlignedMemory(CACHE_LINE_SIZE, sizeof(MSQueueThreadState));
    MSQueueThreadStateInit(th_state, MIN_BAK, MAX_BAK);
    fastRandomSetSeed(id + 1);
    BarrierWait(&bar);
    if (id == 0)
        d1 = getTimeMillis();

    for (i = 0; i < RUNS; i++) {
        MSQueueEnqueue(&queue, th_state, id);
        rnum = fastRandomRange(1, MAX_WORK);
        for (j = 0; j < rnum; j++)
            ;
        MSQueueDequeue(&queue, th_state);
        rnum = fastRandomRange(1, MAX_WORK);
        for (j = 0; j < rnum; j++)
            ;
    }
    return NULL;
}
inline static void *Execute(void* Arg) {
    CCStackThreadState *th_state;
    long i, rnum;
    volatile int j;
    long id = (long) Arg;

    fastRandomSetSeed(id + 1);
    th_state = getAlignedMemory(CACHE_LINE_SIZE, sizeof(CCStackThreadState));
    CCStackThreadStateInit(&object_struct, th_state, (int)id);
    BarrierWait(&bar);
    if (id == 0)
        d1 = getTimeMillis();

    for (i = 0; i < RUNS; i++) {
        // perform a push operation
        CCStackPush(&object_struct, th_state, id, id);
        rnum = fastRandomRange(1, MAX_WORK);
        for (j = 0; j < rnum; j++)
            ; 
        // perform a pop operation
        CCStackPop(&object_struct, th_state, id);
        rnum = fastRandomRange(1, MAX_WORK);
        for (j = 0; j < rnum; j++)
            ;
    }
    return NULL;
}
inline static void *Execute(void* Arg) {
    long i, rnum, mybank;
    volatile long j;
    long id = (long) Arg;
    volatile ToggleVector lactive_set;
    ToggleVector mystate;

    fastRandomSetSeed(id + 1);
    BarrierWait(&bar);
    if (id == 0)
        d1 = getTimeMillis();
    TVEC_SET_ZERO(&mystate);
    TVEC_SET_BIT(&mystate, id);
    mybank = TVEC_GET_BANK_OF_BIT(id);
    for (i = 0; i < RUNS; i++) {
        mystate = TVEC_NEGATIVE(mystate);
        TVEC_ATOMIC_ADD_BANK(&active_set, &mystate, mybank);
        rnum = fastRandomRange(1, MAX_WORK);
        for (j = 0; j < rnum; j++)
            ;
        lactive_set = active_set;
        rnum = fastRandomRange(1, MAX_WORK);
        for (j = 0; j < rnum; j++)
            ;
    }
    return NULL;
}
예제 #4
0
static
PVOID
AtomicDecrementThread(
    PVOID pData
    )
{
    LONG volatile * plValue = (LONG*) pData;
    int i = 0;

    BarrierWait();

    for (i = 0; i < INCREMENT_TIMES; i++)
    {
        InterlockedDecrement(plValue);
    }

    return NULL;
}
inline static void *Execute(void* Arg) {
    long i, rnum;
    volatile int j;
    long id = (long) Arg;

    fastRandomSetSeed(id + 1);
    BarrierWait(&bar);
    if (id == 0)
        d1 = getTimeMillis();

    for (i = 0; i < RUNS; i++) {
        pthread_spin_lock(&lock);
        object = object + 1;
        pthread_spin_unlock(&lock);
        rnum = fastRandomRange(1, MAX_WORK);
        for (j = 0; j < rnum; j++)
            ;
    }
    return NULL;
}
예제 #6
0
static
PVOID
AtomicExchangeThread(
    PVOID pData
    )
{
    PEXCHANGE_INFO pInfo = (PEXCHANGE_INFO) pData;
    LONG lOldValue = 0;

    BarrierWait();

    do
    {
        lOldValue = InterlockedCompareExchange(
            pInfo->plValue,
            pInfo->lNewValue,
            pInfo->lOldValue);
    } while (lOldValue != pInfo->lOldValue);

    return NULL;
}
inline static void *Execute(void* Arg) {
    SimThreadState *th_state;
    long i, rnum;
    long id = (long) Arg;
    volatile long j;

    th_state = getAlignedMemory(CACHE_LINE_SIZE, sizeof(SimThreadState));
	SimThreadStateInit(th_state, id);
    fastRandomSetSeed((unsigned long)id + 1);
    BarrierWait(&bar);
    if (id == 0)
        d1 = getTimeMillis();

    for (i = 0; i < RUNS; i++) {
        SimApplyOp(sim_struct, th_state, fetchAndMultiply, (Object) (id + 1), id);
        rnum = fastRandomRange(1, MAX_WORK);
        for (j = 0; j < rnum; j++)
            ;
    }
    return NULL;
}
inline static void *Execute(void* Arg) {
    OyamaThreadState *th_state;
    long i, rnum;
    volatile int j;
    long id = (long) Arg;

    fastRandomSetSeed(id + 1);
    th_state = getAlignedMemory(CACHE_LINE_SIZE, sizeof(OyamaThreadState));
	OyamaThreadStateInit(th_state);
    BarrierWait(&bar);
    if (id == 0)
        d1 = getTimeMillis();

    for (i = 0; i < RUNS; i++) {
        // perform a fetchAndMultiply operation
        OyamaApplyOp((OyamaStruct *)&object_lock, th_state, fetchAndMultiply, (ArgVal) id, id);
        rnum = fastRandomRange(1, MAX_WORK);
        for (j = 0; j < rnum; j++)
            ;
    }
    return NULL;
}
inline static void *Execute(void* Arg) {
    long i;
    long rnum;
    long id = (long) Arg;
    volatile int j;

    fastRandomSetSeed(id + 1);
    init_pool(&pool_node, sizeof(ListNode));
    BarrierWait(&bar);
    if (id == 0)
        d1 = getTimeMillis();

    for (i = 0; i < RUNS; i++) {
        push((Object)1, id);
        rnum = fastRandomRange(1, MAX_WORK);
        for (j = 0; j < rnum; j++)
            ;
        pop(id);
        rnum = fastRandomRange(1, MAX_WORK);
        for (j = 0; j < rnum; j++)
            ;
    }
    return NULL;
}