Hi,
I have 2 tasks. Task 1 must transmit a packet every 100ms, for this I am using a clock and a semaphore. Task 2 must receive an unknown number of packets that are sent while Task 1 is not transmitting. How can I implement this? are semaphores a feasible approach?
I am trying to use 2 semaphores. May I use just 1 semaphore to enable(disable) task 1 and at the same time disable(enable) task 2?. The 2 tasks should be running exclusively(when one runs, the other stops), but I can not use just 1 thread, because task 2 needs to be receiving an unknown number of frames.
Summarizing, there are 2 tasks:
task 1: Transmits a frame every 100ms.
task 2: Receive an infinite number of packets. Task 2 should run indefinitely, when task 1 is not active.
So the desired behavior is as follows. The clock triggers task 1 to transmit, task 2 stops and task 1 transmits. After that, task 1 finishes the transmission, and task 2 continues in its loop receiving an undefined number of frames. Later on, when the clock tic happens, task 2 stops and task 1 runs, such that a new frame is transmitted by task 1. The operation continues indefinitely.
I have tried many implementations, but at the end the programs hangs, I think the hanging is something similar to the issue in
http://e2e.ti.com/support/wireless_connectivity/f/968/p/384881/1362946#1362946
but I want to be sure that is just the hanging issue and not something wrong in my implementation with semaphores.
Please give me a working example to implement this. Thanks!