undefined states

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
just a quick question,

How do you design your code to prevent it slipping into an undefined
state, i thought all that was needed was to create a default to first
state in case the program slips outside the defined area.

Any help would be greatly appreciated

Re: undefined states

Quoted text here. Click to load it

We need more context to give a useful answer.  In general, stay within
the defined areas of your programming language, tools, and target hardware.

Thad


Re: undefined states
Quoted text here. Click to load it

Just what is 'slipping' in this context?

In any case:

In general, you can't design software that can detect it's
own malfunction.  Search for "halting problem" on the 'net.

The best you can do is a "watchdog timer" or some other
hardware to monitor the software operation.

If the problem is due to programmer error then you can minimize
it by hiring experienced programmers and system testers.

Quoted text here. Click to load it

??????????????

--
Nicholas O. Lindan, Cleveland, Ohio
Consulting Engineer:  Electronics; Informatics; Photonics.
We've slightly trimmed the long signature. Click to see the full one.
Re: undefined states

Quoted text here. Click to load it

Writing a program to default to a given state when things go wrong is
like building a road with guardrails on corners -- it keeps you from
getting into deeper trouble, but it doesn't prevent the original
screw-up.  Careful coding, or using language constructs that don't allow
an illegal state to be assigned, are the only things that will keep
things from screwing up in the first place.

I suggest you follow up this or Mr. Smith's post with a post that tells
what you're trying to do and what's screwing up.  It's most likely that
you're either explicitly writing the wrong value to your state
someplace, or that you've got a pointer wrong and you're writing some
perfectly valid piece of data to a horribly wrong spot.

--

Tim Wescott
Wescott Design Services
We've slightly trimmed the long signature. Click to see the full one.
Re: undefined states

Quoted text here. Click to load it


Undefined states are to be avoided at almost all cost.
This would result in a non-deterministic behaviour.
Therefore : statemachines have to define all states.
Overflows in addition/subtraction and multiplications
have to be trapped or avoided. A division by zero has
also to be trapped or avoided.
In the embedded world, there is command.com that takes
charge - usually.
The watchdog shall be quiet.

Rene

Re: undefined states

Quoted text here. Click to load it
Defensive programming is a must!!!!!!!!!!

gm


Re: undefined states
Use a well defined state machine.

The following article might help:
http://www.eventhelix.com/RealtimeMantra/HierarchicalStateMachine.htm

Deepa
--
http://www.EventHelix.com/EventStudio
EventStudio 2.5 - Embedded System Modeling with Sequence Diagrams


Re: undefined states
Quoted text here. Click to load it


Never thought about it. A finite state machine is often a machine
that's trivial to code for, where some code contains thousands or
millions of states, and the correctness of all combinations of
states is not an interesting question, or even humanly possible
to analyze.

One state might be a system call failure that is not accounted for,
and the code crashes or malfunctions. The obvious prevention for such
is to check the success and not assume. The pitfall here was a
branch, not in the algorithm, but in the machine, that was not
recognized as such.

Re: undefined states
On 8 Jan 2005 05:49:07 -0800, in comp.arch.embedded

Quoted text here. Click to load it

as other people have said, watchdogs are OK

http://www.ganssle.com/watchdogs.htm
and
http://www.embedded.com/showArticle.jhtml?articleID99%00990


martin

 Serious error.
   All shortcuts have disappeared.
      Screen. Mind. Both are blank.

Site Timeline