Page 1 of 1

NEW function OS_Trap()

PostPosted: Sun Jul 21, 2002 10:33 am
by luben

After using SALVO enough time I can tell that it's near to perfection and I almost can't imagine something that is new to it. What really needs now SALVO is to be adjusted to all possible compilers and processors (I'm afraid that this will take more time, then the time you lost for imagine the ketnel).

An idea just came to my mind - what about OS_Trap(&variable,value or mask, _LABEL). It covers my old idea for "emergency" priority or how to break the nowmal order of operation and to jump on special place.

This operator stays somewhere in the task, on place, where usually the program doesn't flow - "emergency" place.

The variable is checked into Sheduler if is equal to the mask, or if it's zero, or something like that. If this is TRUE it brings immediately the operation to TRAP command. Of course, as more variables are watched for tracking, then slowlier becomes the scheduler. Don't forget that the variable could be even the PORT of the processor - so you can track directly the status of one pin, or register.... I know that "emergency" is special area of programming and in all cases you need fast, dramaticly different from normal flow of operation and superpredictable response.

Well, I agree that all what I said could be implemented with current SALVO operators.... I told you, it's near to the perfection :-)

Best regards and lucky week

Re: NEW function OS_Trap()

PostPosted: Sun Jul 21, 2002 10:44 am
by aek
Hi Luben.

Can you post some code snippets of how you might want to use OS_Trap()?



Re: NEW function OS_Trap()

PostPosted: Sun Jul 21, 2002 11:02 am
by aek
Hi Luben.

I think I understand what you want ...

What do you want to happen after the scheduler vectors to the OS_Trap()?

If you put an OS_Yield(traplabel) where your "trap" needs to be, this will (with PICC and PICC-18, at least) create a globally visible traplabel. Then, you can do:

for (;;) {
if ( trap condition ) {
asm("global _traplabel");
asm("ljmp _traplabel");

I haven't tested this, but it should work. You're taking advantage of the fact that with PICC and PICC-18 (but not, for instance, with MPLAB-C18) the OS_Yield() context switcher creates a globally visible label. Then you just jump to it directly ... For stack-based compilers, you'd probably want to use setjmp(), etc.



[This message has been edited by aek (edited July 21, 2002).]