Pumpkin, Inc.

Pumpkin User Forums

NEW function OS_Trap()

Have an idea on how to make Salvo better? Post it here!

NEW function OS_Trap()

Postby luben » Sun Jul 21, 2002 10:33 am

Hello,

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
Luben

luben
 
Posts: 324
Joined: Sun Nov 19, 2000 12:00 am
Location: Sofia, Bulgaria

Re: NEW function OS_Trap()

Postby aek » Sun Jul 21, 2002 10:44 am

Hi Luben.

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

Thanks,

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

-------
aek
aek
 
Posts: 1886
Joined: Sat Aug 26, 2000 11:00 pm

Re: NEW function OS_Trap()

Postby aek » Sun Jul 21, 2002 11:02 am

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:

code:
main() 
{
...
for (;;) {
if ( trap condition ) {
asm("global _traplabel");
asm("ljmp _traplabel");
}
OSSched();
}
}

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.

Regards,

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

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

-------
aek
aek
 
Posts: 1886
Joined: Sat Aug 26, 2000 11:00 pm


Return to Feature Requests

Who is online

Users browsing this forum: No registered users and 1 guest

cron