How to deal with time in C ?

S

srikanth

i have written one C -programm, which outputs signals for specific
input. what my question is, i want to produce outputs for some range of
user inputs. so for this i want to call my programm for every 40ms.
Before, i never dealed with time.

my software is running with linux operation system on a HIL simulator.
- Processor is little endian
- Boot from flash
- Input clock frequency for Excalibur is 20MHz
- SDRAM clock frequency is 133MHz.

Using C-libraries is it possible to get time from any processor??
Could any one please suggest how to proceed for my problem??

Thank you,

srikanth.
 
M

Mehta Shailendrakumar

Hi,

You can use functions alarm() or setitimer(),getitimer() etc.
They are available in linux.

Regards,
Shailendra
 
E

Eric Sosman

pete said:
Jean-Claude Arbaut said:
It's probably not related to the C laguage itself. Maybe
you can have a look at the POSIX standard. Start here:


Try harder.

N869
7.23 Date and time <time.h>
7.23.1 Components of time
[#1] The header <time.h> defines four macros, and declares
several types and functions for manipulating time.

Unfortunately, the <time.h> facilities will not meet the
O.P.'s need, which is for a recurring execution with a 40-ms
period. As Jean-Claude said, he'll need to go beyond Standard
C to achieve this.
 
M

Materialised

srikanth said:
i have written one C -programm, which outputs signals for specific
input. what my question is, i want to produce outputs for some range of
user inputs. so for this i want to call my programm for every 40ms.
Before, i never dealed with time.

my software is running with linux operation system on a HIL simulator.
- Processor is little endian
- Boot from flash
- Input clock frequency for Excalibur is 20MHz
- SDRAM clock frequency is 133MHz.

Using C-libraries is it possible to get time from any processor??
Could any one please suggest how to proceed for my problem??

Thank you,

srikanth.
Thought about using crontab?
 
M

Mac

i have written one C -programm, which outputs signals for specific
input. what my question is, i want to produce outputs for some range of
user inputs. so for this i want to call my programm for every 40ms.
Before, i never dealed with time.

my software is running with linux operation system on a HIL simulator.
- Processor is little endian
- Boot from flash
- Input clock frequency for Excalibur is 20MHz
- SDRAM clock frequency is 133MHz.

Using C-libraries is it possible to get time from any processor??
Could any one please suggest how to proceed for my problem??

Thank you,

srikanth.

Please don't cross-post to comp.lang.c and comp.lang.c++. This is RARELY
productive.

In this case, I believe your question is off-topic in both groups. Perhaps
a group dedicated to the system you are using would be a better choice. If
there is no such group, then maybe a mailing list?

In general, I think it is impossible to guarantee deterministic periodic
operation unless you have a real-time OS, but maybe I'm wrong, somehow.

For more information about comp.lang.c, see the faq:
http://www.eskimo.com/~scs/C-faq/top.html

You can also read this welcome message:
http://www.ungerhu.com/jxh/clc.welcome.txt

I'm sure there are similar resources for comp.lang.c++, but I don't know
where to find them.

--Mac
 
G

Gordon Burditt

Using C-libraries is it possible to get time from any processor??
Thought about using crontab?

You want the OP to use crontab to invoke something every 40
MILLISECONDS? The implementations of crontab I've seen don't even
let you specify seconds. You can do once a minute.

Gordon L. Burditt
 
Y

yatindran

Does your hardware have a timer chip like 8254 or something? in that
case,
int baseAddress, counter0, counter1, counter2;

baseAddress = N; /* your 8254 card's base address in decimal */

counter0 = baseAddress;
counter1 = baseAddress + 1;
counter2 = baseAddress + 2;

use outb functions(family of functions for low level I/O)
outb(counter0,NUM);
and you can program the timer in a convinient mode, and write an
interrupt service routine.I think this will work for "40 milli
seconds."
 
S

srikanth

Thank you for every one , but i still dint follow some answers (as i
told you, in past i never deal with time ).
thank you,
srikanth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top