Pumpkin, Inc.

Pumpkin User Forums

BinSem "evaporating" problem

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

BinSem "evaporating" problem

Postby luben » Wed Jul 11, 2001 4:50 am

Hello,

What are the possible reasons for one BinSem to be lost. Let me explain - I have a task (SERIAL_OUT ) that sends data to serial port (USART). After finishing the sending of data to the port it signals that resources are free (in the beginning the semaphore is set to 1) and other tasks can send messages again. After signalling that serial is free it begins to wait for a new message (the message pointer points to the message, that should be sent, the end of message is 0x00, like normal strings).

1 other task is trying from time to time to get the control over SERIAL_OUT task to send some messages and it waits the BinSem – BINSEM_FREE to be signalled (if signalled – resources are free). All tasks are with equal priority.

The last (3th) task receives data from serial, find out control strings and forces other 2 tasks to do some job, depend on the command. So, this task is like command processor. I used “pseudo_random” recognition of commands – I make to every coming string a CRC polinom control and just compare digits, not strings, works great with almost unlimited number of command strings with any length.

What you have to note is that the project works well, I mean – it hangs from time to time and whole other time it behaves excellent. And it hangs due to “evaporating” of the BINSEM. It’s made on 16F876, so it’s possible that it’s bank problems too.

I marked that from time to time (1time on 300) the 2 tasks begin to wait, the SERIAL_OUT waits the message…. System hanged. All they are waiting each other – it’s so called “dead lock”, explained in your manual. The reason of this “hanged system” is (I get this with setting some debbug variables) that BINSEM_FREE is not signaled and somehow disappeared. This happens in different time (I mean – there is no law … accidentally). The last one speaks for possible ISR problems or hidden SALVO intertask communication problems, correct? From other side I can’t figure out how one BINSEM can disappear… but the fact is – the BINSEM from time to time disappeared. I don’t have deep call procedures at all, with exception of one division of long variable.

I know that SALVO meaning of BINSEM is to hold data, and if you mark I don’t ask why SALVO lost semaphores. For sure the reason is outside of SALVO, the bad news is that I don’t know even where to look.

My request is: can you bring me some advice where and how to search the problem?

Luben

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

Re: BinSem "evaporating" problem

Postby aek » Wed Jul 11, 2001 8:53 am

Can you post some code samples? Or e-mail them? Be sure to include your salvocfg.h. Send a whole MPLAB project if you need to.

quote:
What you have to note is that the project works well, I mean – it hangs from time to time and whole other time it behaves excellent.

That's not acceptable -- it should work all the time, without error. What you're doing is encapsulating a resource by first waiting for the binsem, using the resource, and then releasing the binsem. With all tasks at the same priority, as long as you always get the resource (OS_WaitXyz()), use it, and then release it (OSSignalXyz()), you should be OK. Keep in mind that you cannot wait a resource from within an ISR.

I doubt banking is a problem -- but keep in mind that the Salvo Lite libraries place all Salvo variables in bank1. You can't change that.

If you're using ISRs, then are you using the appropriate library?

I suspect it's simply a minor oversight -- perhaps you're using the wrong library.

[This message has been edited by aek (edited July 11, 2001).]

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


Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest

cron