timer_create creates thread - Linux

This is a discussion on timer_create creates thread - Linux ; Hi, I am developing an application on the montavista platform which uses the timer_create api to create timers as following: timer_event.sigev_notify = SIGEV_SIGNAL; timer_event.sigev_signo = SIGRTMIN; timer_event.sigev_value.sival_ptr = data; sigfillset (&timer_action.sa_mask); timer_action.sa_flags = SA_SIGINFO ; /* realtime signal */ timer_action.sa_sigaction ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: timer_create creates thread

  1. timer_create creates thread

    Hi,

    I am developing an application on the montavista platform which uses
    the timer_create api to create timers as following:

    timer_event.sigev_notify = SIGEV_SIGNAL;
    timer_event.sigev_signo = SIGRTMIN;
    timer_event.sigev_value.sival_ptr = data;

    sigfillset (&timer_action.sa_mask);
    timer_action.sa_flags = SA_SIGINFO ; /* realtime signal */
    timer_action.sa_sigaction = timer_handler;
    sigaction (SIGRTMIN, &timer_action, NULL);

    /* Create the timer */
    if( timer_create (CLOCK_REALTIME, &timer_event, &timer_id) !=0 ) {
    return -1;
    }

    I've noticed that the timer_create api calls clone which in turn
    creats a thread.
    #0 0x00becf70 in clone () from /lib/tls/libc.so.6
    #1 0x001619ae in do_clone () from /lib/tls/libpthread.so.0
    #2 0x001615f6 in create_thread () from /lib/tls/libpthread.so.0
    #3 0x00160f9d in pthread_create@@GLIBC_2.1 () from /lib/tls/
    libpthread.so.0
    #4 0x00fbd909 in __timer_thread_start () from /lib/tls/librt.so.1
    #5 0x00fbc659 in compat_timer_create () from /lib/tls/librt.so.1
    #6 0x00fbc371 in timer_create () from /lib/tls/librt.so.1

    However, this thread doesn't seem to go away once the timer has
    expired. It seems to be stuck in pthread_cond_wait.

    #1 0x003ba006 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/
    libc.so.6
    #2 0x00e6de5a in thread_func () from /lib/tls/librt.so.1
    #3 0x00645dd8 in start_thread () from /lib/tls/libpthread.so.0
    #4 0x003acfca in clone () from /lib/tls/libc.so.6

    Is there any way I can get the thread to terminate or use any other
    option which causes in threads not being created ?

    Thanks.

    -- Achint

  2. Re: timer_create creates thread

    On Jul 9, 1:28*pm, Achint Mehta wrote:

    > However, this thread doesn't seem to go away once the timer has
    > expired. It seems to be stuck in pthread_cond_wait.


    > Is there any way I can get the thread to terminate or use any other
    > option which causes in threads not being created ?



    Do you have an actual problem? Why do you care about internal
    implementation details?

    DS

  3. Re: timer_create creates thread

    Achint Mehta writes:
    > I am developing an application on the montavista platform which uses
    > the timer_create api to create timers as following:
    >
    > timer_event.sigev_notify = SIGEV_SIGNAL;
    > timer_event.sigev_signo = SIGRTMIN;
    > timer_event.sigev_value.sival_ptr = data;
    >
    > sigfillset (&timer_action.sa_mask);
    > timer_action.sa_flags = SA_SIGINFO ; /* realtime signal */
    > timer_action.sa_sigaction = timer_handler;
    > sigaction (SIGRTMIN, &timer_action, NULL);
    >
    > /* Create the timer */
    > if( timer_create (CLOCK_REALTIME, &timer_event, &timer_id) !=0 ) {
    > return -1;
    > }
    >
    > I've noticed that the timer_create api calls clone which in turn
    > creats a thread.


    [...]

    > However, this thread doesn't seem to go away once the timer has
    > expired. It seems to be stuck in pthread_cond_wait.


    [...]

    > Is there any way I can get the thread to terminate or use any other
    > option which causes in threads not being created ?


    setitimer

+ Reply to Thread