Timer Function ? 
Author Message
 Timer Function ?

Quote:

>I'm making an applicaton for Solaris (in C) and need to execute
>some pieces of code at specific timepoints.
>It would help me a lot if I could define some timers and then just
>wait until one of them expires.
>Does it exist some functions for that ??

The C language doesn't define any functions to do that. Unix has ways of
doing this but those should be discussed in comp.unix.programmer.

--
-----------------------------------------


-----------------------------------------



Thu, 24 Aug 2000 03:00:00 GMT  
 Timer Function ?


writes:

Quote:

>I'm making an applicaton for Solaris (in C) and need to execute
>some pieces of code at specific timepoints.
>It would help me a lot if I could define some timers and then just
>wait until one of them expires.
>Does it exist some functions for that ??

Just use wait loop with  clock() or time().

Aloha



Sat, 26 Aug 2000 03:00:00 GMT  
 Timer Function ?



Quote:

>writes:

>>I'm making an applicaton for Solaris (in C) and need to execute
>>some pieces of code at specific timepoints.
>>It would help me a lot if I could define some timers and then just
>>wait until one of them expires.
>>Does it exist some functions for that ??

>Just use wait loop with  clock() or time().

Busy looping is something you should *never* do in a multitasking OS. Also
clock() isn't appropriate here since it measures CPU time; the interval
that the program waited would be affected enormously by any other activity
in the system. There is no satisfactory portable solution to this program
so the correct answe is to use whatever platform-specific extensions are
available.

--
-----------------------------------------


-----------------------------------------



Mon, 28 Aug 2000 03:00:00 GMT  
 Timer Function ?

And for the very common platform, you need some documentation on Windows API
calls.

Tim



Mon, 28 Aug 2000 03:00:00 GMT  
 Timer Function ?


Quote:
(Lawrence Kirby) writes:
>>>wait until one of them expires.
>>Just use wait loop with  clock() or time().
>Busy looping is something you should *never* do in a multitasking OS.

There is no such thing as commonly used none-multitasking OS.
Your statement is just to reduce the load on cpu.

Quote:
>Also clock() isn't appropriate here since it measures CPU time; the interval
>that the program waited would be affected enormously by any other activity

This depends of what other person want to do.  For example, if he want
to do things that only needs to be 'about' certain period, it might even
be desirable to do it less often when there's heavier load on the system.

Quote:
>There is no satisfactory portable solution to this program

There's usually going to be a room for a low priority task in most of
environment, though this will not be satisfactory in multi user environment
with high cpu utilization.

Quote:
>so the correct answe is to use whatever platform-specific extensions are
>available.

I for one always believe in using extensions that make things more than
slightly better.  OTOH, in C (not in C++) this is somewhat like 'interrupt' vs.
'pulling' in which case I wouldn't be using 'interrupt' unless there's other
tasks needing cpu.  So correct answer is it depends on what you want to do,
environment, and speed at which developement has to occur etc.

Aloha



Tue, 29 Aug 2000 03:00:00 GMT  
 Timer Function ?



Quote:

>(Lawrence Kirby) writes:

>>>>wait until one of them expires.

>>>Just use wait loop with  clock() or time().

>>Busy looping is something you should *never* do in a multitasking OS.

>There is no such thing as commonly used none-multitasking OS.

I don't think I commented on that either way. Still, DOS is far from dead
and then there are embedded systems and other smaller systems. So I don't
think your statment bears much relation to reality.

Quote:
>Your statement is just to reduce the load on cpu.

You mkae it sound like a minor consideration. IN a multitasking environment
it isn't.

Quote:
>>Also clock() isn't appropriate here since it measures CPU time; the interval
>>that the program waited would be affected enormously by any other activity

>This depends of what other person want to do.  For example, if he want
>to do things that only needs to be 'about' certain period,

It is still a bad idea to base time intervals on unrelated conditions.
Lets  say you wanted a time interval of "about" an hour. With a system
load of 20 you might get an avctual interval of "about" a day. Basing
something on unrelated unknowns is fankly very poor programming practice.

Quote:
>it might even
>be desirable to do it less often when there's heavier load on the system.

If that is what you want there will almost certainly be better ways of
achieving it on the system in question.

Quote:
>>There is no satisfactory portable solution to this program

>There's usually going to be a room for a low priority task in most of
>environment, though this will not be satisfactory in multi user environment
>with high cpu utilization.

Since you can't even portably create a low priority task, this can in no
way be considered a satisfactory portable solution.

Quote:
>>so the correct answe is to use whatever platform-specific extensions are
>>available.

>I for one always believe in using extensions that make things more than
>slightly better.

I agree but this is an example where that is very much the case since there
is no adequate portable solution.

Quote:
> OTOH, in C (not in C++) this is somewhat like 'interrupt' vs.
>'pulling' in which case I wouldn't be using 'interrupt' unless there's other
>tasks needing cpu.  So correct answer is it depends on what you want to do,
>environment, and speed at which developement has to occur etc.

Again if the answer depends on your environment then the answer isn't
going to be portable.

--
-----------------------------------------


-----------------------------------------



Thu, 31 Aug 2000 03:00:00 GMT  
 Timer Function ?


Quote:
(Lawrence Kirby) writes:
>>>>Just use wait loop with  clock() or time().

>>>Busy looping is something you should *never* do in a multitasking OS.

>>There is no such thing as commonly used none-multitasking OS.

>I don't think I commented on that either way. Still, DOS is far from dead
>and then there are embedded systems and other smaller systems. So I don't
>think your statment bears much relation to reality.

Well, DOS is commonly loaded with Windows, some BBS might be
running with DesqView etc.  Also, technically printer spooling and
write-back cache is a background task though most people will
not consider it part of multi-tasking.  I am pretty sure that there
are lots other program that check for InDOS flag.  Also, DOS is
one place where it is rather common to have 'busy wait'.  I believe
most likely that embedded keyboard processor is doing idle loop.

Quote:
>>Your statement is just to reduce the load on cpu.

>You mkae it sound like a minor consideration. IN a multitasking environment
>it isn't.

I consider PC/MAC to be 90%+ of multitasking programing / computer
environment where this is can be minor consideration.  

Quote:
>>>Also clock() isn't appropriate here since it measures CPU time; the
>interval
>>>that the program waited would be affected enormously by any other activity

>>This depends of what other person want to do.  For example, if he want
>>to do things that only needs to be 'about' certain period,

>It is still a bad idea to base time intervals on unrelated conditions.
>Lets  say you wanted a time interval of "about" an hour. With a system
>load of 20 you might get an avctual interval of "about" a day. Basing
>something on unrelated unknowns is fankly very poor programming practice.

time() should be use for anything that is longer than couple seconds.

Beside, no matter what (even if you use extensions) some fast timing cannot
be set depending on the machine .   Infact, OS/2 3.0 will default to suspend
some task up to 3 second when things are busy.

Quote:
>>it might even
>>be desirable to do it less often when there's heavier load on the system.

>If that is what you want there will almost certainly be better ways of
>achieving it on the system in question.

Not always, for example there's commonly used term video frame rate
per second.  It will be important for video card and monitor to sync to fixed
frequency, but screen change/update can be non-fixed rate.  This way
people with higher capable hardware can enjoy higher quality of experience.

Quote:
>>>There is no satisfactory portable solution to this program

>>There's usually going to be a room for a low priority task in most of
>>environment, though this will not be satisfactory in multi user environment
>>with high cpu utilization.

>Since you can't even portably create a low priority task, this can in no
>way be considered a satisfactory portable solution.

Just because there will be some inefficiency or unsatisfaction
in few situations, it doesn't mean it isn't useful or it isn't portable.
For example, there's no 'satisfactory' way of running Linux on 8088 PC with
64k of RAM.  It will probably wouldn't even run satisfactory on 386SX with
1meg ram system.  This doesn't mean that Linux is not portable.  

Quote:
>>I for one always believe in using extensions that make things more than
>>slightly better.

>I agree but this is an example where that is very much the case since there
>is no adequate portable solution.

I agree that it will be undesirable in heavily loaded environment.

Quote:
>> OTOH, in C (not in C++) this is somewhat like 'interrupt' vs.
>>'pulling' in which case I wouldn't be using 'interrupt' unless there's other
>>tasks needing cpu.  So correct answer is it depends on what you want to do,
>>environment, and speed at which developement has to occur etc.

>Again if the answer depends on your environment then the answer isn't
>going to be portable.

Similarly, there might not be any solution for some environment.
If there is no screen or other display in a system, user
will not see the output of printf("Can you see this?\n");

Aloha



Sat, 02 Sep 2000 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. building timer function with time.h

2. Need help with timer function

3. Timer function in Ansi C

4. Timer function

5. Timer function in VC++?

6. Timer function(I'm lost!)

7. Timer function problem, weird results.

8. Newbie question about printing text and timer function

9. Timer function(I'm lost!)

10. Periodic Timer Function

11. Timer function needed

12. Reliable timer function?

 

 
Powered by phpBB® Forum Software