Hello,

kirthika varadaraja wrote:
> I just created a thread inside the thread i need to create an event for
> every 5 min.
> ...
> I refered to DM6467, there the timers are in kernel and i am not able to
> link it in my application.

This is standard C library stuff really, but since I hate when people give
that answer...
You don't need to create a thread for this, just use alarm() and you'll get
a SIGALRM.
>From there, you can post to a semaphore or whatever.

See: http://docs.linux.cz/programming/c/unix_examples/alarm.html

But, since you asked, if you don't want to use alarm(), like you have some
other work
that could be done in the thread, you could do this:

--- SNIP ---

volatile int global_TerminateAlarmThread = 0;
sem_t global_AlarmEvent; /* Initialized in main() */

void *
alarm_thread_main(void *arg)
{
   int *pSeconds = (int *) arg;
   while(!global_TerminateAlarmThread)
   {
      /* Uses CLOCK_REALTIME here - watch out for time/date changes */
      sleep(*pSeconds);
      sem_post(&global_AlarmEvent);
   }
   pthread_exit(0);
   return 0;
}

--- END ---

It's sort of what the kernel does anyhow for you though, except using
signals...

Regards,
David

--
DAVID A. KONDRAD
Software Design Engineer
On-Q/Legrand
Telephone (800) 321-2343 x311
www.onqlegrand.com


_______________________________________________
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to