[<prev] [next>] [day] [month] [year] [list]
Message-ID: <4BC04440.17716.2AAF4DA@Frantisek.Rysanek.post.cz>
Date: Sat, 10 Apr 2010 09:26:24 +0200
From: "Frantisek Rysanek" <Frantisek.Rysanek@...t.cz>
To: linux-kernel@...r.kernel.org
CC: bill o gallmeister <bog.kernel@...il.com>
Subject: Re: setitimer vs. threads: SIGALRM returned to which thread? (process master or individual child)
On 9 Apr 2010 at 23:26, bill o gallmeister wrote:
>
> Check out timer_create() rather than setitimer().
>
Oh I *see* :-) There seems to be a way to deliver an event to a
specific thread. Just a quick guess, haven't validated this by a
compiler:
============ PSEUDOCODE SNIPPET ==========
struct my_thr_data
{
pthread_t ID; /* to be set upon pthread_create() */
/* ...further members... */
};
void* my_fn(void* my_user_data)
{
pthread_kill( ((my_thr_data*)my_user_data)->ID, SIGALRM);
}
struct my_thr_data this_thread;
timer_t my_timer;
struct sigevent my_event =
{
sigev_notify: SIGEV_THREAD,
sigev_notify_function: my_fn,
sigev_value.sival_ptr: &this_thread,
sigev_notify_attributes: NULL
}
timer_create(CLOCK_REALTIME, &my_event, &my_timer);
/* by now we're set up, but the timer doesn't tick yet. */
/* someplace later in the code: */
timer_settime(my_timer, ... );
=========== /PSEUDOCODE SNIPPET ==============
thank you :-)
Frank Rysanek
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists