|
|
|
|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
How to implement polling for a function using timer in C?
Hi,
Can you please help me in implementing a timer based polling for function in C? ie. the function should be called in say 30secs(when 30secs has lapsed). Thanks |
| Sponsored Links | ||
|
|
|
|||
|
Suppose if I have put the alarm in a function, and i need to catch the signal only inside the function, is it possible? ie. the process should be executing in the normal manner till it reaches this function and catches the signal.
|
|
|||
|
Quote:
signal driven IO (SIGIO or SIGALRM) is very rarely used and hard to get right. Then the modern approach is using select or poll in a thread. |
|
|||
|
Depends what it's supposed to fit in. If you are writing a program from scratch then there is no problem with Code:
main()
{
while (1)
{
sleep(30);
doCheck();
}
}If it's an Xt based client application then use one of the timer callback functions. It all depends what framework it has to work in. |
|
|||
|
This has to be implemented in a deamon process in UNIX system. The daemon waits for any messages in a message queue and parallely has to go and execute a function by polling in every 30secs.
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Want to implement VLOOKUP (Excel function) in Unix | pravani1 | Shell Programming and Scripting | 8 | 05-26-2008 05:08 AM |
| Polling/Interrogate Directory Questions | dnidiffer | Shell Programming and Scripting | 1 | 06-14-2005 10:20 PM |
| timer | k_oops9 | Shell Programming and Scripting | 3 | 11-08-2004 11:33 AM |
| how to implement timer | Frank2004 | AIX | 2 | 06-09-2004 10:21 PM |
| Help - Polling Script | brianmu | Programming | 1 | 09-06-2001 11:15 AM |