I have to make a C program which has to perform a specified event at a specified time. Something like this...

Print Hello at 13:15
Print Bye at 14:20
Print working at 13:57

Assume that these instructions are already available. I am thinking of creating a doubly linked list which will hold the hour, minute & the text. Then, I will sort them, keeping the earliest event at the start of the list. The problem now is how to make sure that the required event occurs at the very moment that it is supposed to occur. I am thinking that I might require a sort of program that would periodically check the current time(hour, then minute) with that stored in the list. But how should I do this? Also, is there a more efficient way of performing this sort of check?

10 Years
Discussion Span
Last Post by Narue

There are plenty of C features considering time. Read up on them.

The linked list approach seems efficient enough for this task.


I think sleep would be a good option...but is it the only one? Also what happens if I initiate a sleep & after that I get a command from the user saying that a certain instruction has to performed before the previous 1st instruction. Is it then possible to update the sleep time accordingly?


>i would this in DOS using TSR program to fire events with....
I would too...15 years ago, and only on DOS because TSRs were a hack to get around the weaknesses of an OS that couldn't handle more than one running program at a time. Now I'd use the event management or polling mechanisms of whatever multitasking OS the program is written for.

>Is it then possible to update the sleep time accordingly?
Yes, but then you're entering the realm of multiple threads/processes. One thread polls for changes to the requirements and another performs work based on the currently saved requirements.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.