473,473 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Timer 9600/s

Hi,
Is it possible to create timer 9600/s in C?

Regards,
Rafal
Nov 15 '05 #1
8 1631
Rafal M wrote:
Hi,
Is it possible to create timer 9600/s in C?


Depends on your filesystem. Many do not allow spaces
or slashes in the file names. However, you will need
to ask on a newsgroup dedicated to you OS, as this one
does not handle OS based problems.

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 15 '05 #2
Rafal M wrote on 02/09/05 :
Is it possible to create timer 9600/s in C?


Not in standard C. You need some hardware ans system resource.
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"Mal nommer les choses c'est ajouter du malheur au
monde." -- Albert Camus.
Nov 15 '05 #3
In article <df**********@inews.gazeta.pl>,
Rafal M <ra********@gazeta.pl> wrote:
Is it possible to create timer 9600/s in C?


If you mean a timer that invokes a signal handler 9600 times every
second, then the answer is "No, not portably".

If you mean a timer that is accurate to within 1/9600 of a second
when it is examined, then the answer is "No, not portably".

If you mean a timer that can signal an event after 9600 seconds,
then the answer is "No, not portably".

Portable C does not offer any facilities for triggering actions
after particular lengths of time (at any precision), and the
highest resolution time-of-day counter it has is clock()
which increments CLOCKS_PER_SEC times a second. I do not see any bounds
imposed on CLOCKS_PER_SEC at the moment; if I recall correctly
one of the standards imposes a minimum bound on CLOCKS_PER_SEC,
but I do not recall which standard it is.
--
Any sufficiently advanced bug is indistinguishable from a feature.
-- Rich Kulawiec
Nov 15 '05 #4


Walter Roberson wrote:
[...]
Portable C does not offer any facilities for triggering actions
after particular lengths of time (at any precision), and the
highest resolution time-of-day counter it has is clock()
which increments CLOCKS_PER_SEC times a second. [...]


First, clock() measures CPU time, not time of day.
For the latter, you need time().

Second, the clock() value does not necessarily increment
CLOCKS_PER_SEC times per second, nor even per CPU second.
The value is *stated* in units of 1/CLOCKS_PER_SEC seconds,
but that doesn't imply that it's *measured* in those units.

--
Er*********@sun.com

Nov 15 '05 #5
Rafal M wrote:
Hi,
Is it possible to create timer 9600/s in C?

Regards,
Rafal


Why 100us not work (is slow)?

HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime;

liDueTime.QuadPart=-1000 // 100ns*1000 =100us

// Create a waitable timer.
hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer");
while (true)
{
SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, 0);
if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0)
{
printf("failed");
}
else
{
printf("T");
}
}
Nov 15 '05 #6
In article <df**********@news1brm.Central.Sun.COM>,
Eric Sosman <er*********@sun.com> wrote:
Walter Roberson wrote:
Portable C does not offer any facilities for triggering actions
after particular lengths of time (at any precision), and the
highest resolution time-of-day counter it has is clock()
which increments CLOCKS_PER_SEC times a second. [...]
First, clock() measures CPU time, not time of day.
For the latter, you need time().
Sorry, brain lapse.
Second, the clock() value does not necessarily increment
CLOCKS_PER_SEC times per second, nor even per CPU second.
The value is *stated* in units of 1/CLOCKS_PER_SEC seconds,
but that doesn't imply that it's *measured* in those units.


You are of course correct; at the time of my writing I was casting
around for better wording but couldn't think of any then.
--
'The short version of what Walter said is "You have asked a question
which has no useful answer, please reconsider the nature of the
problem you wish to solve".' -- Tony Mantler
Nov 15 '05 #7
Rafal M <ra********@gazeta.pl> writes:
Rafal M wrote:
Is it possible to create timer 9600/s in C?


Why 100us not work (is slow)?

HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime;

liDueTime.QuadPart=-1000 // 100ns*1000 =100us

// Create a waitable timer.
hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer");
while (true)
{
SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, 0);
if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0)
{
printf("failed");
}
else
{
printf("T");
}
}


That code fragment is extremely system-specific, and therefore
off-topic in this newsgroup. I don't even know what system it applies
to.

--
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.
Nov 15 '05 #8
Keith Thompson wrote on 02/09/05 :
Rafal M <ra********@gazeta.pl> writes:
hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer");
That code fragment is extremely system-specific, and therefore
off-topic in this newsgroup. I don't even know what system it applies
to.


It probably is Microsoft (MSDN).

http://msdn.microsoft.com/library/de...tabletimer.asp

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"It's specified. But anyone who writes code like that should be
transmogrified into earthworms and fed to ducks." -- Chris Dollin CLC
Nov 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
2
by: DaveF | last post by:
I am trying to write a service to fire an ftp object off. I want to wait 2 minutes and then download the files. Then repeat every 2 minutes. The files just seem to stop downloading. Does that timer...
9
by: HL | last post by:
I am using VS 2005 Beta - C# Problem: The Timer fires a few milliseconds before the actual Due-Time Let's say a timer is created in the following manner: System.Threading.Timer m_timer = null;...
2
by: John David Thornton | last post by:
I've got a Windows Service class, and I put a System.Threading.Timer, and I've coded it as shown below. However, when I install the service and then start it in MMC, I get a peculiar message: ...
12
by: Gina_Marano | last post by:
I have created an array of timers (1-n). At first I just created windows form timers but I read that system timers are better for background work. The timers will just be monitoring different...
8
by: =?Utf-8?B?RGF2ZSBCb29rZXI=?= | last post by:
I have a Timer that I set to go off once a day, but it frequently fails! In order to debug I would like to be able to check, at any moment, whether the Timer is enabled and when it will next...
0
by: klw40 | last post by:
Visual Basic 2005 project will only move data at 9600 baud even when port and baud slection can be selected by user. klw40
16
by: Peter Oliphant | last post by:
Note that although this involves SAPI, it is more a question about Timers and event handlers. I wrote a Speech Recognize handler (SAPI), and put some code in it to enable a Timer. It would not...
7
by: seegoon | last post by:
Hi to all. I have a application that receives data via the serial port. I don't know the number of bytes that are going to be coming in. It could be 10 up to 150. (9600 baud) I have decided to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.