timer_create fails (return=-1 errno=0)

Rich Felker dalias at aerifal.cx
Wed Oct 19 19:46:46 UTC 2011


On Wed, Oct 19, 2011 at 02:24:49PM +0000, Grant Edwards wrote:
> On 2011-10-19, Rich Felker <dalias at aerifal.cx> wrote:
> > On Tue, Oct 18, 2011 at 08:42:52PM +0000, Grant Edwards wrote:
> >
> >> For now, I'm rewriting the code to use SIGEV_SIGNAL.
> >
> > If you want thread delivery, it would be easiest to just make a thread
> > that enters a loop calling clock_nanosleep to sleep until the next
> > intended wakeup time then calls your callback function...
> 
> That would be a lot of wheel-reinventing.  I don't really feel like
> re-implementing an entire timer subsystem with a sorted-list of timer
> intervals and functions to insert/remove/set/reset/enable/disable
> timers.

I would just do a dedicated thread for each time and no management
structures. Let the kernel manage it for you.

> It's way simpler to use SIGEV_SIGNAL and then set up a thread that
> calls sigwaitinfo() in a loop waiting for the timer signal.  The
> kernel's quite good at keeping track of timers and figuring out when
> the next one times. :)

That works, as long as you block the signal in all other threads. I
was worried about async signal safety issues, which don't come into
play with your approach.

Rich


More information about the uClibc mailing list