You are here

Add new comment

rncbc's picture

maybe it's because you're locking/unlocking the mutex in tight sequence in the main line loop?

try this pattern instead:

pthread_mutex_lock(&updateThreadMutex);

while (updateThreadIsRunning)
{
    pthread_cond_wait(&updateThreadCv, &updateThreadMutex);

    ModSynth::get_instance()->update_tasks(0);

    prvStartts.tv_usec = startts.tv_usec;
    gettimeofday(&startts, NULL);

    fprintf(stderr, "Time from last block: %i Time from prev block end time [us]: %i\n", startts.tv_usec- prvStartts.tv_usec, startts.tv_usec - stopts.tv_usec);
    .
    .
    .
    gettimeofday(&stopts, NULL);
}

pthread_mutex_unlock(&updateThreadMutex);

seeya