Pumpkin, Inc.

Pumpkin User Forums

Events & OS_Yield

If you can't make Salvo do what you want it to do, post it here.

Events & OS_Yield

Postby ChrisV » Wed Jan 24, 2001 9:59 am

1.If i have 3 events: ALARM, KEYPAD, DISPLAY, are they to be difined as follows: #define ALARM 0 #define KEYPAD 1 #define DISPLAY 2?

2. If I have several "if" statements in a task and I need the program to signal a semaphore and break out of that task if any of the "if" statemnts are true, is it neccesary to put a OS_Yield after each OSSignalBinSem()?

ChrisV
 
Posts: 10
Joined: Wed Jan 24, 2001 12:00 am
Location: Chandler, AZ

Re: Events & OS_Yield

Postby Salvo Tech Support » Wed Jan 24, 2001 10:21 am

Hi ChrisV.

1) Yes, that would work, as long as you have

code:
#define OSEVENTS 3

in your salvocfg.h. Events are numbered 0 to OSEVENTS-1. In other words, the indeces that you use to refer to events must range from 0 to OSEVENTS-1. If an index is outside of that range, the results are unpredictable.

2) You could do that, but it would return to the next line in the task, which is perhaps not what you want... You could do the following instead:

code:
void TaskA (void)
{
for (;;) {
for (;;) {
...
if (condition1) {
OSSignalBinSem(...);
break;
}

...
if (condition2) {
OSSignalBinSem(...);
break;
}

...
if (condition3) {
OSSignalBinSem(...);
break;
}

break;
}
OS_Yield(label);
}
}


VERY IMPORTANT NOTE: In order to use the C break statement in this manner, the "extra" for() loop (or while(), do() or switch()) is required. The behavior of TaskA() above is as follows: as soon as a condition is met, the binSem is signaled, and then the task yields to the scheduler. The next time the task runs, it will start again at the top of the inner for loop and evaluate the conditions from top to bottom. Note that this infers a priority scheme (has nothing to do with Salvo) upon the various conditional tests. The final break statement in the nested for() loop ensures that you don't get stuck there forever.

--------
Salvo Technical Support
Please request all tech support through the Forums.
Salvo Tech Support
 
Posts: 173
Joined: Sun Nov 19, 2000 12:00 am


Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest

cron