示例#1
0
void
iterateLife(
    LIFE_T *life)
{
    memcpy(life->field, life->fieldNext, life->fieldLength);

    if (life->numberOfThreads == 0)
    {
        iterateLifeKernel(life, 0);
    }
    else
    {
        pthread_barrier_wait(&(life->startIterationBarrier));
        pthread_barrier_wait(&(life->finishedIterationBarrier));
    }

    int result = 0;
    VC_IMAGE_TYPE_T type = VC_IMAGE_RGBA16;

    result = vc_dispmanx_resource_write_data(life->backResource,
                                             type,
                                             life->pitch,
                                             life->buffer,
                                             &(life->bmpRect));
    assert(result == 0);
}
示例#2
0
void *
workerLife(
    void *arg)
{
    LIFE_T *life = arg;

    int32_t thread = -1;
    int32_t i;
    for (i = 0 ; i < life->numberOfThreads ; i++)
    {
        if (pthread_equal(pthread_self(), life->threads[i]))
        {
            thread = i;
            break;
        }
    }

    if (thread == -1)
    {
        fprintf(stderr, "life: cannot find thread index\n");
        return NULL;
    }

    while (true)
    {
        pthread_barrier_wait(&(life->startIterationBarrier));
        iterateLifeKernel(life, thread);
        pthread_barrier_wait(&(life->finishedIterationBarrier));
    }

    return NULL;
}
示例#3
0
void *
workerLife(
    void *arg)
{
    LIFE_T *life = arg;

    int32_t thread = -1;
    int32_t i;
    for (i = 0 ; i < life->numberOfThreads ; i++)
    {
        if (pthread_equal(pthread_self(), life->threads[i]))
        {
            thread = i;
        }
    }

    while (true)
    {
        pthread_barrier_wait(&(life->startIterationBarrier));
        iterateLifeKernel(life, thread);
        pthread_barrier_wait(&(life->finishedIterationBarrier));
    }

    return arg;
}