The FAQ mentions that there are some problems with condition variables and I
seem to get false reports about destroying waited on condition variables from
Helgrind. I'm using really simple code like the following:

struct linted_array_queue
{
    pthread_mutex_t mutex;
    pthread_cond_t on_empty;
    pthread_cond_t on_full;
    size_t message_size;
    bool occupied;
    char message_buffer[];
};

static void unlock_routine(void* arg)
{
    pthread_mutex_t* mutex = arg;
    pthread_mutex_unlock(mutex);
}

void linted_array_queue_send(struct linted_array_queue* queue,
                             void const* message)
{
    pthread_mutex_lock(&queue->mutex);
    pthread_cleanup_push(unlock_routine, &queue->mutex);

    while (queue->occupied) {
        pthread_cond_wait(&queue->on_empty, &queue->mutex);
    }

    queue->occupied = true;
    memcpy(queue->message_buffer, message, queue->message_size);

    pthread_cond_signal(&queue->on_full);

    pthread_cleanup_pop(true);
}

I think it is correct but maybe Helgrind can't deal with condition variables and
cancellation. Is there any metadata or markup I can use to please Helgrind?

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to