Reduce memory usage with Mutex Semaphore

slicetex wrote on Tuesday, March 08, 2011:

Hi,

I need to create 30 mutex semaphores for shared resources.

Each mutex uses a queue, so 30 x 76 bytes = 2280 bytes…too much RAM for
my MCU.

My question is, How I can implement mutex or similar mechanism without using too RAM ?.

Thanks in advance.

Regards,
Boris Estudiez.-

http://www.slicetex.com.ar

davedoors wrote on Tuesday, March 08, 2011:

My question would be, why do you need 30 mutexes? Are you sure you have an optimal design?

rtel wrote on Tuesday, March 08, 2011:

Mutexes have a lot to do - they have all the event information contained within them (instead of in a separate event control block), control how things queue waiting for the mutex, ensure things queue in priority order, implement priority inheritance, allow blocking on mutex receives, etc.  If you need all that, then use a mutex, if you don’t and your usage scenario is more simply, then you can implement something more simply, even some sort of protected shared variable might do.

Regards.

slicetex wrote on Tuesday, March 08, 2011:

Hi, I need 30 mutexes becouse I have a script running on two tasks (A & B).

Task A and B share the same resources. Task B has higher priority than task A.

In my device,  the script is loaded by a customer, so the access to the shared resources
must be transparent.

I need priority inheritance when task B try to access to the resources.

Regards,
Boris Estudiez.-