473,320 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

delay

In my multi threaded application(windows), I have several infinite
loop(though it's not good to have...but I need them). Hence they eat
nearly 98% of CPU time(it shows in task manager).

I have decided to put a delay of 200 ms in the program. But
unfortunately my Compiler(Borland 5.5) is not providing any such
functionalities.

In my research, I found that many (lame) people put delay by putting
unnecessary instructions in the delay block....like this

void delay()
{
int i=0,j=10;
for(i=0;i<12345678;i++)
j *=j;
}

But it won't do my job. But I have found that by doing some kind of
signal handling, I can create my delay function.

Does such functionality is available in windows ????
How can I implement it ????

Oct 7 '08 #1
11 4419
On 7 Oct 2008 at 7:13, asit wrote:
In my multi threaded application(windows), I have several infinite
loop(though it's not good to have...but I need them). Hence they eat
nearly 98% of CPU time(it shows in task manager).

I have decided to put a delay of 200 ms in the program. But
unfortunately my Compiler(Borland 5.5) is not providing any such
functionalities.

But it won't do my job. But I have found that by doing some kind of
signal handling, I can create my delay function.

Does such functionality is available in windows ????
How can I implement it ????
On POSIX systems, the function you're looking for is called sleep(3) and
can be implemented using the SIGALRM signal.

Doing a Google search for
"Windows API" sleep
shows that the corresponding Windows function is called Sleep with a
capital S, and takes a long int argument specifying the length of time
to wait in milliseconds.

Oct 7 '08 #2
Antoninus Twink wrote:
On 7 Oct 2008 at 7:13, asit wrote:
>In my multi threaded application(windows), I have several infinite
loop(though it's not good to have...but I need them). Hence they eat
nearly 98% of CPU time(it shows in task manager).

I have decided to put a delay of 200 ms in the program. But
unfortunately my Compiler(Borland 5.5) is not providing any such
functionalities.

But it won't do my job. But I have found that by doing some kind of
signal handling, I can create my delay function.

Does such functionality is available in windows ????
How can I implement it ????

On POSIX systems, the function you're looking for is called sleep(3) and
can be implemented using the SIGALRM signal.
Utter nonsense. sleep(3) suspendeds execution for a number of seconds.
The correct POSIX function would be nanosleep(). SIGALRM is a total
red herring.

--
Ian Collins.
Oct 7 '08 #3
On 7 Oct 2008 at 7:48, Ian Collins wrote:
Antoninus Twink wrote:
>On POSIX systems, the function you're looking for is called sleep(3)
and can be implemented using the SIGALRM signal.
Utter nonsense. sleep(3) suspendeds execution for a number of
seconds. The correct POSIX function would be nanosleep().
As usual, you deliberately misunderstand.

The OP's question was about Windows, and the only point of mentioning
POSIX was to find the correct synonymn for delay (namely sleep) that
results in a successful Google search.

Try googling
"Windows API" nanosleep
and see how useful the results are.
SIGALRM is a total red herring.
The OP asked whether delay functions can be implemented using signals.
In principle, the answer is clearly yes, as demonstrated by alarm(2).
The fact that its argument is a time in seconds doesn't change the fact
that it works by delivering a SIGALRM to the calling process.

Oct 7 '08 #4
The problem is that i don't use Visual C++, I use Borland C++ 5.0.
Oct 7 '08 #5
On 7 Oct 2008 at 8:33, asit wrote:
The problem is that i don't use Visual C++, I use Borland C++ 5.0.
Surely you can access the Windows standard library with any C or C++
compiler?

Oct 7 '08 #6
On 7 Oct, 09:33, asit <lipu...@gmail.comwrote:
The problem is that i don't use Visual C++, I use Borland C++ 5.0.
the problem is you are on the wrong news group.
Please post your problem to a suitable Microsoft newsgroup.

Oct 7 '08 #7
On Oct 7, 1:46 pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
wrote:
On 7 Oct, 09:33, asit <lipu...@gmail.comwrote:
The problem is that i don't use Visual C++, I use Borland C++ 5.0.

the problem is you are on the wrong news group.
Please post your problem to a suitable Microsoft newsgroup.
thanx friends....

finally I solved my problem.
the required function is Sleep(int milisec)
now my keylogger is not eating much resources ...

Oct 7 '08 #8
[off-topic]

Antoninus Twink <no****@nospam.invalidwrites:
On 7 Oct 2008 at 7:48, Ian Collins wrote:
>SIGALRM is a total red herring.

The OP asked whether delay functions can be implemented using signals.
In principle, the answer is clearly yes, as demonstrated by alarm(2).
The fact that its argument is a time in seconds doesn't change the fact
that it works by delivering a SIGALRM to the calling process.
Certainly sleep(3) can be implemented via alarm(2), and historically
has been, but isn't always. On my system it just calls nanosleep(2).
Oct 7 '08 #9
Antoninus Twink wrote:
On 7 Oct 2008 at 8:33, asit wrote:
>The problem is that i don't use Visual C++, I use Borland C++ 5.0.

Surely you can access the Windows standard library with any C or C++
compiler?
Sleep is a basic windows function accessible from both compilers.

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Oct 7 '08 #10
asit <li*****@gmail.comwrites:
In my multi threaded application(windows), I have several infinite
loop(though it's not good to have...but I need them). Hence they eat
nearly 98% of CPU time(it shows in task manager).

I have decided to put a delay of 200 ms in the program. But
unfortunately my Compiler(Borland 5.5) is not providing any such
functionalities.
[...]

Questions about Windows-specific functions will generally get better
and quicker answers in comp.os.ms-windows.programmer.win32 or in one
of the microsoft.* groups.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Oct 7 '08 #11
jacob navia wrote:
Antoninus Twink wrote:
>asit wrote:
>>The problem is that i don't use Visual C++, I use Borland C++ 5.0.

Surely you can access the Windows standard library with any C or
C++ compiler?

Sleep is a basic windows function accessible from both compilers.
The point is the 'sleep' is not an available function in standard
C. If you want it available, go to a newsgroup that deals with
whatever non-standard system you are using. It is off-topic on
c.l.c. You will have a hard time accessing the Windows standard
library on a Linux system, for example.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Oct 7 '08 #12

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

Similar topics

14
by: Des L. Davis | last post by:
System: Dell PowerEdge Server with 3 GB RAM, 2.4 GHz Celeron Software: Microsoft SQL Server 2000 Enterprise running on Windows 2003 Server Software: Microsoft SQL Server 2000 Enterprise running on...
2
by: amos_s12 | last post by:
Hello everybody Is there a possibility to make a delay between two sql statements, namely one sql statement is performed, then there is a delay of some seconds and then rhe next statement is...
6
by: lucifer | last post by:
hi i need to insert delay in my program what function should i use the old delay is not supported by the VC6
20
by: Doug Thews | last post by:
I ran into an interesting re-pain delay after calling the Abort() method on a thread, but it only happens the very first time I call it. Every time afterward, there is no delay. I've got a...
11
by: Maheshkumar.R | last post by:
Hi groups, How i can introduce some milliseconds delay in application. How i can do achieve this... let me clearly say... (1) I'm displaying slices of medical images. For framerate - for...
7
by: mfeingold | last post by:
I am working on a system, which among other things includes a server and a ..net control sitting in an html page and connected to the server. I ran into a couple of problems, you guys might have...
4
by: Jeremy S | last post by:
I have written an ASP.NET application that performs very well. I make heavy use of the Cache and otherwise minimize the number of round trips to to the db. I couldn't be happier with the...
18
by: Max | last post by:
This is a follow-up on my previous thread concerning having the program wait for a certain date and time and then executing some code when it gets there. My question is; can I use the Sleep...
4
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I make a 10 second delay? ----------------------------------------------------------------------- There...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.