0
votes

I'm working on a project with 5 different sensors. I have 4 tasks (I'm using freeRTOS, and I'm relatively new to using embedded OS'es):

  1. sensor_manager which will read the sensors and put the data in a queue (which will be a data structure) (priority: 3)
  2. LED_manager which will take (peek) data from the queue and turn on the appropriate LEDs (priority: 2)
  3. display_manager which will also peek from the queue and update a TFT display (priority: 1)
  4. xively_manager which will also peek from the queue and upload the data to a web service called Xively. (priority: 0)

Questions:

  1. I want the system to work in the exact order as I've described. The problem I have is deciding on whether to use a binary semaphore or a counting semaphore to synchronize between these tasks; they all have to take turns accessing the queue containing the sensor data .
    1. Will each task have to "take" the semaphore in the beginning and "give back" the semaphore at the end of the task? Suggestions are greatly appreciated! Please direct me to any web sources that adequately explain the use of semaphores.
1
Counting semaphores ( > 1) are for cases where you allow more than one thread in the critical section. If your queue does not support that then binary semaphore is your choice. - gidim

1 Answers

0
votes

1,you need a semaphore to sync the task execution by order. you should makesure that led, display, xively task take one data from queue in one cycle.

2,you have a "Production and Consumption" problem. you say you task peek the queue, maybe this will be ok:led,display task peek the queue, and xively take the data from the queue.