[haiku-development] Re: correct way to acquire_sem_etc()

  • From: "François Revol" <revol@xxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 30 Oct 2008 00:45:47 +0100 CET

> > Anyone who can send unmasked signals to the current thread can
> > interrupt.
>
> The suspend_thread() + resume_thread() combo does also interrupt, so
> does

Right, SIGSTOP/SIGCONT.

> > Sometimes, even in locking primitives, it's done as
> > while (acquire_sem_etc(s, B_CAN_INTERRUPT, ...) == B_INTERRUPTED);
> >
> > This might be to eat signals and avoid delaying them instead,
> > though
> > I'm not sure.
> > I've seen that in the NFS addon code for ex.
> > It can't be to let the thread handle the signal, as it won't be
> > done
> > until it actually exit from the syscall...
>
> If that is done in kernel code, it's buggy. Signals are only handled
> right
> before leaving the kernel, that is this would become a busy loop.

Do you mean it would always return B_INTERRUPTED while only 1 signal
arrived ??
I always thought it would only happend on the call that actually cought
it.
And it'd look saner to me.
Actually, doesn't R5 work that way ?

François.

Other related posts: