Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
329 views
in Technique[技术] by (71.8m points)

alarm function on Linux and Windows -> can't find a equivalent for Windows -> C

I have worked for some time now on Linux and done some C programs, and now I need to build an app for windows but is not being easy to find a replacement for the alarm function (found on signal.h)...

The thing is, in Linux, when you set the alarm flag as SIGALRM (if not mistaken), what the OS is going to do is to execute some function when the alarm goes off. Example:

signal(SIGALRM, myfunc);
alarm (2);

What is going to happen on this example is the OS is going to call the function myfunc every 2 seconds (in windows is going to be miliseconds probably, but don't mind that detail right now).

I've searched for some time how to do the same on windows (only using windows.h atm) but I can't find a replacement for that (searched thousands of times on msdn), and, on windows there is no SIGALRM flag on the signal.h.....

What can I use in C to do the same behaviour as the alarm with the SIGALRM flag?(In other words, a function that allows to execute another function using an alarm or similar).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Check the MSDN for timeSetEvent. It's not exactly the same as alarm, but may be close enough.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...