This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

semaphore in a SWI

Other Parts Discussed in Thread: SYSBIOS

Hello all,

I'm using a omap l138 with sysbios 6.33.04.39.

My problem is that I try to protect one of my function(SPI_ADC, this function read the values on a ADC) that I call in a task and a swi(timer interupt). I can't use semaphore because there are only use in the task. Can I use something else that I will able to pend and post in the swi and a task. Like that I will protect the function to be call in two place at the same time. I try GateMutex, event and sync but the problem is they all using the semaphore function...

I now the easy way will be to create 2 function(SPI_ADC_TASK and SPI_ADC_SWI) but this will not politically correct :)

Thank for your help

  • Hi,

    You can use GateSwi. When you "enter", it disables all Swis (and Tasks) from running. When you "leave", it re-enables Swis (and Tasks). As always try to minimize the work when you are in the gate and do not call any blocking functions (e.g. Task_sleep, etc.).

    Todd

  • Hi Todd,

    Thanks for the quick answer.

    I try the GateSwi and i got error that said that I can't use GateSwi in a Hwi... So I suppose that the timer interrupt is consider as a Hwi. :S

    So I try the GateHwi_enter fonction and I verify if the task will be disable but the task is still run even if I never use the GateHwi_leave function.

    I think I will force to disable the task during I complet my SPI_ADC function. It is possible to stop just one task? or I need to stop all of them?

    Thanks

  • If you can GateHwi_enter (or Hwi_disable) only the executing thread (Hwi, Swi or Task) will run. This is a very fundamental part of SYS/BIOS. Can you check your logic? Please note you cannot call anything that might block (e.g. Task_sleep, etc.).

    There is no synchronization mechanism that blocks a single Task and interrupts.

  • ok, I will modify my logic to be able to use semaphore.

    Thanks for your help