"Rod Pemberton" <do*********@bitfoad.cmmwrites:
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
>"Rod Pemberton" <do*********@bitfoad.cmmwrites:
"paresh" <pa************@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
I need to set timer in C/linux like alram, such that i will get a
timeout signal after specific timeout and my process remain executing
as is it.
I can use signal(SIGALRM, xyz) and then alarm(some value in sec), there
is a constraint in this as i can pass timeout only in seconds and i
need in milli sec.
Any idea how todo this.
This is a frequently asked question. C doesn't have any high resolution
timer functions.
True.
What you need is assembly code for your OS. The 'rdtsc'
instruction will work for IA-32 platforms.
What makes you think assembly code is the answer?
You've asked me that twice in the past. I answered twice. Try to
remember.
Sorry, I've forgotten. A Google Groups search indicates that you've
discussed the rdtsc instruction here before; apparently I didn't find
any of those discussions very memorable.
You'll want some GCC code (similar) to this:
[snip]
I seriously doubt it.
And, one again you show your abundant ignorance of anything
immediately outside the boundaries of the C specification...
If it's outside the boundaries of the C specification, it's off-topic
for this newsgroup. I admit that I don't know much about x86 assembly
language. That's why I don't post to comp.lang.asm.x86.
In any case, if I understand the code you posted correctly, it uses
the rdtsc instruction to load the value of the system's high
resolution time-stamp counter. The original poster was looking for a
high-resolution timer that would send his program a signal after a
specific timeout. Your code does nothing like that. You've provided
a chunk of code that (a) is entirely off-topic in this newsgroup, (b)
is extremely system-specific (and compiler-specific), and (c) doesn't
even address what the OP was asking about.
To the original poster: There is no way to do what you're trying to do
in portable C. There most likely is a system-specific way to do it,
*without* resorting to assembly language. I suggest that the
system-specific "setitimer" function might or might not be a good
starting point. (I make no specific claims about that; I've never
used it myself, and it's off-topic here.) Consult your system's
documentation. If you have any further questions, please post to
comp.unix.programmer.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.