Page 1 of 1

Signal not received

PostPosted: Mon Nov 26, 2007 2:22 am
by Pere Mateu
Hi,

I'm having a very strange problem with two tasks.

TaskA uses TaskB as a service. It starts TaskB with a message, and then waits for a semaphore from TaskB that indicates that processing has finished.

TaskB is a higher priority task which is always waiting for the message from TaskA. When it completes its processing, it signals a semaphore to TaskA to indicate that processing has finished.

No other tasks are using these messages.

The code looks like this:

code:
void TaskA(void) {
while (1) {
.
.
.
OSProtect();
OSSignalMsg(TASK_B_START,(OStypeMsgP)'R');
OSUnprotect();
OS_WaitSem(TASK_B_END,OSNO_TIMEOUT,TaskA1);
.
.
.
}
}

void TaskB(void) {
while (1) {
OS_WaitMsg(TASK_B_START,&msgP,OSNO_TIMEOUT,TaskB1);
.
.
//do some processing
.
.
OSProtect();
OSSignalSem(TASK_B_END);
OSUnprotect();
}
}


This works fine for some time, but after some seconds both tasks get blocked. After some debugging I've discovered that both tasks are waiting for each other: TaskA is waiting for TASK_B_END and TaskB is waiting for TASK_B_START.

How can this be happening?

I've checked the result of OSSignalMsg(TASK_B_START) in TaskA and it's always OSNO_ERR, so the signaling seems to be correctly done.

I'm using PIC18F4620, HI-TECH PICC18 v9.51 and MPLAB v8.

Any help would be greatly appreciated.
Thanks very much.

[This message has been edited by aek (edited November 26, 2007).]


Re: Signal not received

PostPosted: Mon Nov 26, 2007 6:51 am
by aek
Looks OK to me .. sounds like either one or both of the task control blocks were corrupted (is OSEVENTS the correct value?), or there is unintended signaling of one or both of the events from there or elsewhere.

BTW, you are calling both OSSignalBinSem() and OSSignalMsg() from ISRs?

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


Re: Signal not received

PostPosted: Tue Nov 27, 2007 4:12 am
by Pere Mateu
I've done more debugging and I've found that the problem is in TaskA. By using an external task, I've seen that TASK_B_END is correctly signaled, but TaskA is in state OSTCB_TASK_WAITING, when it should be in OSTCB_TASK_SIGNALED, I guess.

I can't debug the OStcbArea in MPLab. Any idea why?


Re: Signal not received

PostPosted: Tue Nov 27, 2007 12:43 pm
by Pere Mateu
I forgot a couple of things:

1. Salvo version is v3.2.3
2. TaskA is signaling TasbkB very frequently (20-30 times per second).

OSEVENTS is 6 in total. In theory there's no other signaling of these events elsewhere.

I'm calling OSSignalSem() and OSSignalMsgQ() from my ISR, but not for these tasks.

How can I check if the task control blocks are being corrupted?

Thanks for the quick answer.