LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to call function?? (https://www.linuxquestions.org/questions/programming-9/how-to-call-function-57262/)

harpal 04-29-2003 03:24 AM

how to call function??
 
i have a txt file of ipv6 addresses. I'm trying to code a function that will maintain these address. the structure of the file is as below

anycast_address timer unicast_address

it needs to automaticlly invoke by itself or somehow every 15 mins(to check if timer has hit 0)

i put this function along with other function in a .h file. As the fucntion will be a infinite loop function(always check the every 15 mins) I dont know where or how to call it? I need to call once and only once ......anybody can help??

yrraja 04-29-2003 04:45 AM

If you know anything about signal handling in Linux, then you can use SIGALRM signal for this task. You can set the alarm to be generated every 15minutes and this signal will invote you function.

Second option would be to launch a saperate thread in which you launch this function whcih sleeps for 15minutes and then wakeup and performs the task and then goes back to sleep for 15 minutes.

Yaser

harpal 04-29-2003 05:46 AM

do you have an example or know where i can find one.....
thanks...

yrraja 04-29-2003 05:59 AM

If you have "Unix Network Programming" by Richard Stevens then you can look it up to see how to install a signal, and how to set the timer values for the SIGALRM signal.

For threads just search for 'Posix Thread Tutorial' in google and you will get load of tutorials telling with example code how to do it. One of the tutorials is at this link

http://dis.cs.umass.edu/~wagner/thre.../tutorial.html

If the purpose of your function is only to check the timer value and set some flag based on its value then i would recomment using SIGALRM. Otherwise go for threads.

Yaser


All times are GMT -5. The time now is 12:20 PM.