Re: [PATCH] RFC: futex: make futex_lock_pi interruptible

From: Arnd Bergmann
Date: Fri Oct 30 2009 - 05:14:18 EST


On Friday 30 October 2009, Darren Hart wrote:
> Darren Hart wrote:
> This appears to work fine. Can anyone think of a reason why this is an unsafe
> thing to do? I'll have to create a much more elaborate test case and review
> the glibc code of course to make sure the glibc mutex state isn't compromised.

The only reason I can see against it is the need to use one of the
rt signal numbers from library code, which may conflict with other
users of the signal. Being able to avoid a signal altogether would
be really nice, as in the futex_cancel extension you mentioned.

> /* Need some kind of per-thread variable here */
> jmp_buf env;
> pthread_mutex_t mutex;

Maybe instead of per-thread variables (which should work
fine), you could do

typedef struct {
jmp_buf env;
pthread_mutex_t mutex;
} interruptible_mutex_t;

> /* ensure the child has blocked on the lock */
> sleep(1);

In a real application, you might want to add some logic to avoid
this kind of race. For the test case, you probably need to do it
with the sleep.

Arnd <><
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/