This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Strange error locking a pthread mutex...
- From: "Bert Wesarg" <bert dot wesarg at googlemail dot com>
- To: "Kris van Rens" <krisvanrens dot list at gmail dot com>
- Cc: libc-help at sourceware dot org
- Date: Thu, 22 May 2008 23:10:42 +0200
- Subject: Re: Strange error locking a pthread mutex...
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=9xL208cH06yRZlAF9Zs/JiHjc60r10Us/y8BtYNZ6O4=; b=UhJAHlBK1kG5u0VOUJ897Y8IzeUJK2Azg9nFlFa+IBlHlNWqNrngxTcOMnPjJbv7ncjQEB3blvfuZJKhsC2n3vJ0V0to1A/u+F0HgHRWf1mq5KPss7Cim/ii5Dpjlypn3nKB3Wj1ppXkW4I+oRWjTvmGYxRrZ/m7+LNzqK6SB4A=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=GaXPqa1cbwJCRrCaOht06Gw0JX9fM5kWD4mpZjm27qGOl59MzkUra6PuyJRSKaidwGBFoimTXhDibskCqXebjF9TtcL+rtDVPy75hakFKviHtzxCRdFJaca73s+Ql6kMA0pOq/4+h6PsxqupTVLeMKUK+VsvBSUf9O1nHKHgCC8=
- References: <acb938930805220920t48708c55j7cb3872a8945847c@mail.gmail.com>
On Thu, May 22, 2008 at 6:20 PM, Kris van Rens
<krisvanrens.list@gmail.com> wrote:
> Hi there,
>
> I'm experiencing peculiar problems using a pthread mutex in my
> program. Let me try to explain the setup of the program:
>
> There is a main thread which initializes a recursive mutex for use
> within (multiple) event threads running along the main thread, the
> mutex is used for (what a surprise) outlining a critical section.
>
> Here is a diagram (plaintext, ASCII-art):
>
> +------------------+
> | main() thread |
> +------------------+
> | ... |
> | initialize mutex |
> | ... |
> | spawn threads ---+-------------+------------------------+-------------//
> | ... | | |
> = = +------------------+ +------------------+
> +------------------+ | event thread1 | | event thread2 |
> +------------------+ +------------------+
> | ... | | ... |
> | lock mutex | | lock mutex |
> | <critical stuff> | | <critical stuff> |
> | unlock mutex | | unlock mutex |
> | ... | | ... |
> +------------------+ +------------------+
>
> The mutex variable is declared globally and initialised in the main thread.
>
> ---(globally)
> pthread_mutex_t CritSec;
> ---
>
> The initialisation of the mutex is being done as follows:
>
> ---
> pthread_mutexattr_t mutexattr;
>
Just guessing: no pthread_mutexattr_init()!
> // Set the mutex as a recursive mutex
> pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE_NP);
>
Bert