Hi guys,
is there any utility available as a protection against endless_loop()
something like this:
alarm.set(5); //set timeout for 5 sec
endless_loop();
alarm.reset(); //reset it to 0, as alarm not needed any more
Thanks, 3 3515
<an*****@yahoo. comwrote in message
news:11******** **************@ j72g2000cwa.goo glegroups.com.. .
Hi guys,
is there any utility available as a protection against endless_loop()
something like this:
alarm.set(5); //set timeout for 5 sec
endless_loop();
alarm.reset(); //reset it to 0, as alarm not needed any more
Thanks,
Perhaps there exists such a utility, but as it
would not be standard C++, it would not be topical
here. However, a simple way to implement this would
involve instrumenting the loop itself. Before
the loop begins, capture a time with std::clock(),
and at one or more points inside the loop, capture
the time again. The difference between it and the
one obtained outside the loop would give elapsed time.
Compare it with your desired 'time-out' value. Break
the loop if elapsed time >= your time-out value.
See standard library documentation for details on
how to use 'std::clock()'.
-Mike
On Dec 2, 7:13 am, anki...@yahoo.c om wrote:
Hi guys,
is there any utility available as a protection against endless_loop()
something like this:
alarm.set(5); //set timeout for 5 sec
endless_loop();
alarm.reset(); //reset it to 0, as alarm not needed any more
pesudo code:
int flag = 0;
main(){
signal(SIGALRM, alarm_handler)
while (1) {
if (flag == 1)
break;
}
}
void alarm_handler()
{
flag = 1;
}
Actually, alarm signal will break the blocked system call.
Thanks,
an*****@yahoo.c om wrote:
Hi guys,
is there any utility available as a protection against endless_loop()
Testing?
Anything else would be either intrusive, or platform specific
(signals/watchdog timers).
--
Ian Collins. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bill H |
last post by:
I have a typical username/password check against mysql type logon that
Zone Alarm Pro seem to break... I haven't bought or troubleshooted
this yet, I'm hoping this is a know issue with a simple fix?? ;) :)
TIA for any insights!
Bill
|
by: na1paj |
last post by:
here's a simple linked list program. the DeleteNode function is
producing an infinit loop i think, but i can't figure out where..
#include <stdio.h>
typedef struct
{
char *str; //str is a dynamic array of characters
int length; //number of characters
} String;
|
by: Sergey |
last post by:
How to send alarm to a thread?
I can set alarm in main thread, but how then send exception to another thread to wake it if it executes too long?
|
by: Adrian Casey |
last post by:
I have a multi-threaded python application which uses pexpect to connect to
multiple systems concurrently. Each thread within my application is a
connection to a remote system. The problem is when one of the child
threads runs a command which generates an unlimited amount of output. The
classic example of this is the "yes" command. If you
execute "pexpect.run('yes')", your cpu will sit at 100% forever.
Here is a simple multi-threaded...
|
by: puntino |
last post by:
Hi
I have developed an Alarm, I haven' problem of runtime or compiletime but the application seems blocked.
When I call the method AlarmExecute, it runs only the first time ( when i click onto run button of Eclipse), I seen only one time the hour in the console!
please could anyone help me.
This the code
import java.util.Timer ;
public class Alarm {
private int s;
| |
by: thelightkeeper |
last post by:
Hi,
in MSSQL, I have 2 tables naming ,
---------------------------------------
EquipmentID : nvarchar(50), FK, reference .EquipmentID
AlarmID : nvarchar(50), PK
AlarmHappenTime : Datetime ,required, not null
AlarmClearTime : Datetime, required, not null
|
by: Alan Isaac |
last post by:
Goal: turn off an audible alarm without
terminating the program. For example,
suppose a console program is running::
while True:
sys.stdout.write('\a')
sys.stdout.flush()
time.sleep(0.5)
I want to add code to allow me to turn off
|
by: Alexnb |
last post by:
I am wondering what is the best way to create a timer, like an alarm, once it
reaches a time, it triggers an event. I have a way of doing this but it
seems like it isn't good at all. If it helps at all I am using a Tkinter,
but that probably doesn't mean much. The way I was doing it was using a
while loop, and just saying while current time is not = to trigger time, do
nothing, and when it is, do event.
--
View this message in context:...
|
by: superleochen |
last post by:
Database is simliar to this:
ID TIME TAGNAME VALUE
5967383 8/1/2008 1:00:24 AM I16MUDL11 ALARM
5967384 8/1/2008 1:00:24 AM I16MUDL09 ALARM
5967391 8/1/2008 1:00:32 AM I16MUDL11 A_OK
5967392 8/1/2008 1:00:32 AM I16MUDL09 A_OK
5967398 8/1/2008 1:00:36 AM I16MUDL11 ALARM...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |