User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 403,520 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,818 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 1120 | Replies: 5
Reply
Join Date: May 2008
Posts: 31
Reputation: champnim is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
champnim champnim is offline Offline
Light Poster

How to trigger events at specific times?

  #1  
Jul 7th, 2008
Hi
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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2008
Posts: 142
Reputation: Clockowl is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
Clockowl Clockowl is offline Offline
Junior Poster

Re: How to trigger events at specific times?

  #2  
Jul 7th, 2008
There are plenty of C features considering time. Read up on them.

The linked list approach seems efficient enough for this task.
Reply With Quote  
Join Date: Dec 2005
Posts: 3,411
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 21
Solved Threads: 389
Colleague
Salem's Avatar
Salem Salem is offline Offline
void main'ers are DOOMed

Re: How to trigger events at specific times?

  #3  
Jul 7th, 2008
Work out the time between "now" and the time at the head of the list.
Sleep for that amount?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Reply With Quote  
Join Date: Jan 2008
Posts: 2
Reputation: lighthead is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
lighthead lighthead is offline Offline
Newbie Poster

Re: How to trigger events at specific times?

  #4  
Jul 8th, 2008
i would this in DOS using TSR program to fire events with....
but now..i don't know if it works....
Reply With Quote  
Join Date: May 2008
Posts: 31
Reputation: champnim is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
champnim champnim is offline Offline
Light Poster

Re: How to trigger events at specific times?

  #5  
Jul 8th, 2008
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?
Reply With Quote  
Join Date: Sep 2004
Posts: 6,074
Reputation: Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of 
Rep Power: 26
Solved Threads: 419
Super Moderator
Narue's Avatar
Narue Narue is offline Offline
Expert Meanie

Re: How to trigger events at specific times?

  #6  
Jul 8th, 2008
>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.
I'm a programmer. My attitude starts with arrogance, holds steady at condescension, and ends with hostility. Get used to it.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the C Forum

All times are GMT -4. The time now is 1:11 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC