Hi all,

Need some info on "how to use or implement timers/threads/polling mechanism in c language".
Need to run the same piece of code on both platforms(windows + linux).

Can anyone of you guys suggest me something :)

Thanks in advance!

~Manoj

Recommended Answers

All 2 Replies

windows and *nix have different implementations so you can't use the same program for both.

For MS-Windows you include <windows.h>. You can use threads by calling CreateThread() in console programs, but I think it will requires a win32 windows program to successfully use the SetTimer() and KillTimer() functions because the program needs an event handling function.

I don't know what you mean by a "polling" mechanism.

windows and *nix have different implementations so you can't use the same program for both.

For MS-Windows you include <windows.h>. You can use threads by calling CreateThread() in console programs, but I think it will requires a win32 windows program to successfully use the SetTimer() and KillTimer() functions because the program needs an event handling function.

I don't know what you mean by a "polling" mechanism.

Hi,
Thanks for the quick reply!

I am a bit confused, I was under the impression that timers internally use the createThread() method and we dont have to call this method explicitly. Anyways I will check that.

One more query: Any idea about *nix, what all libraries we need to include OR what all functions we need to call (I am aware of pthread).

~ Manoj

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.