Pumpkin, Inc.

Pumpkin User Forums

Priority and Signaling events

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

Priority and Signaling events

Postby luben » Thu Jun 07, 2001 8:29 am

Hello,

I have some quastions about the way of processing events and their relation with priorities.

Imagine that you have 3 tasks, let’s say TASK_A (priority 2), TASK_B (priority 7) and TASK_Display (priority 7).

TASK_Dsiplay process coming messages (MESS_Display) and after the message is already on the screen signals one BinSem (BinSem_Display_free) that recources are free.

Before signaling the messages every tasks waits to find the semaphore BinSem_Display_free is signaled. This prevents any troubles and mistakes with the resources (RAM, used to keep messages).

code:

//====================================
void TASK_A(void)
//====================================
{
……..
OS_WaitBinSem(BinSem_Display_free, LABEL1);
// waits forever to get the resources of Display task
// -------- POINTA

OSSignalMsg(MESS_Display, &Message0);

// -------- POINTB

OS_WaitBinSem(BinSem_Display_free, LABEL2);
// try to take control again to avoid any other tasks to use display

// -------- POINTC

………..
}

//====================================
void TASK_B(void)
//====================================
{
……..

OS_WaitBinSem(BinSem_Display_free, LABEL3);
// waits forever to get the resources of Display task

// -------- POINTD

OSSignalMsg(MESS_Display, Message1);

}


My question is:
What is the order to pass trougth the test points, if the fisrt point is POINTA.

It should be (if I understood correctly SALVO) POINTA, POINTB, POINTC, POINTD, because TASKA has the highest priority.

Somewhere in the forum we spoke about the way of signaling and getting the events. If when we signal the event we calculate IN THAT MOMENT which is the next waiting task for it, then the order will become POINTA, POINTB, POINTD, POINTC. Because in the moment of signaling the event, TASKA is still not starting the process of waiting the event.

In short, if we signal one event where SALVO calculates the next task that will be executed – in the OSSched(), or in the OSSignalXYZ()?

I’m 98% sure that this happens in the OSsched(), but 2% unsure is enough to bring me big troubles on some “thiny” place.

Regards and good luck with new SALVO Millenium 2.2 
Luben

[This message has been edited by luben (edited June 07, 2001).]

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

Re: Priority and Signaling events

Postby Salvo Tech Support » Thu Jun 07, 2001 10:12 am

Hi Luben.

In your example, who signals the binSem?

Assuming it's TASK_Display(), then you're right, it will be A, B, C, D, assuming that the binSem is signaled some time after C and before TASK_A() waits on it again. For example, if TASK_A() delays for a long while after C, then TASK_B() will get a chance to send its message to the display.

Here's how to understand how it works: At any time, tasks are either eligible or waiting (plus some other states, but they don't matter here). The act of signaling an event causes the most eligible waiting task to be added to the eligible queue. This happens during OSSignalXyz(). So signaling an event can change the eligible queue. The scheduler simply takes the most eligible task and runs it.

Put another way, when multiple tasks wait an event, the highest-priority one will always be made eligible when the event is signaled. The lower-priority tasks "will get their chance" when there's no other task ahead of them, waiting for the event.

So, in your words, it's happening in OSSignalXyz().

------------------
-----------------------
Salvo Technical Support
Please request all tech support through the Forums.

[This message has been edited by Salvo Tech Support (edited June 07, 2001).]

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

Re: Priority and Signaling events

Postby Salvo Tech Support » Thu Jun 07, 2001 10:13 am

I forgot to mention that v2.2.0 is now released and on the website. Just download the Salvo Lite installer and go!

P.S. Check out salvodemod4sysh. It's a freeware-based demo that runs on the MPLAB-ICD.

------------------
-----------------------
Salvo Technical Support
Please request all tech support through the Forums.

[This message has been edited by Salvo Tech Support (edited June 07, 2001).]

--------
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 3 guests

cron