Page 1 of 1

OSInit() behaviour

PostPosted: Sat Nov 24, 2001 8:45 am
by luben
Hello,

Almost one week I tried to locate a strange unpredictable error into my graphic thermal printer project. In fact it worked nice but hanged from time to time (like stack overflow) and sometimes printed wrong characters, sometimes didn't wait on OS_WaitXYZ() despite that event was not signalled. I even suspected that SALVO2.2 has some bug.

What was my surprise when I get that I just forgot to add OSInit() into my file at all. As you wrote in the manual - without starting OSInit before any other SALVO services the results are unpredictable. If you ask me, the perfect behaviour should be - without starting OSInit() SALVO will be locked and system should stop.

So, maybe you should add some flag into SALVO, let's say - OSFLAG_INITIALIZED, if it's not set the system will be blocked (OSShed will hang). The flag could be set only in OSInit(). This will prevent of using SALVO without initializing.

The idea of such flag is to narrow the possibility one user to start SALVO with wrong parameters, or like my case - without initializing.

I even think that similar initial checking should be done for events and tasks. Well, this is more complicated, because in initial
state not all tasks could be active.

Other approach is to use SALVO project wizard, something that can check the project for correct SALVO settings (in salvocfg.h) , tasks and events definitions. And of course to help the user to create initial SALVO settings.

Regards
Luben


Re: OSInit() behaviour

PostPosted: Sat Nov 24, 2001 9:00 am
by aek
Hi Luben.

The issue of OSInit() is a little more complicated ... and has mainly to do with minimizing memory usage. Since ANSI requires that variables not explicitly initialized be set to 0 by the time you reach main(), almost all of Salvo's variables have an initialized value of 0. It costs ROM to set things to other than 0, and so we want to avoid that.

Also, for persistent variables (see demod3 for an example thereof), it's better to maintain a standard set of all-0's for everything.

Therefore, most applications will work without calling OSInit() at all, from a source-code build. The PICmicro libraries, on the other hand, are build with OSLOC_ALL set to bank1 persistent, which means that those variables are left at their power-on state (i.e. random), and so OSInit() is required.

In other words, OSInit() is usually required, but there are times when it should not be used.

How did you build the project? Source code or libraries?

------------------

[This message has been edited by aek (edited December 02, 2001).]