Messages in this thread | | | From | "Frantisek Rysanek" <> | Date | Sat, 10 Apr 2010 09:26:24 +0200 | 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
| |