sasikalaswathi wrote on Monday, November 04, 2019:
Created the event group with one set_task and 3 read_bits_tasks.
vEventBitSettingTask which sets the bit 0,bit 1 and bit 2.
vEventBitReadingTask -wait to read the bit 0
vEventBitReadingTask1 -wait to read the bit 1
vEventBitReadingTask 2-wait to read the bit 2
All tasks are same priority. Here are the things which needs clarfication.
- Irrespective of setting and waiting for the bits to set , all tasks will run until particular time slice expires(Switch between tasks of equall priority will occur on every tick interrupt)? but in API xEventGroupSetBits, Setting bits in an event group will automatically unblock tasks that are blocked waiting for the bits.
While checking the output via printf, i get the following output:
Setting bit task output -
AFTER BIT 0 set
AFTER BIT 1 set:
AFTER BIT 2 set
AFTER BIT 0 set
AFTER BIT 1 set:
AFTER BIT 2
read_bit task output:
bit 0 was set
bit 1 was set
bit 2 was set
While saw the output, the task which setting the bits (bit 0, bit 1, bit 2) will executes again even after the bit set right? here after one iteration of event bit set, control will not automatically unblock tasks that are blocked waiting for the bits.
- In second case, i slightly change the tasks vEventBitSettingTask,vEventBitSettingTask1 and vEventBitSettingTask2 to wait for the same bit (bit 0) .Here the parameter of xClearOnExit set to pdTRUE.
As a result, only one task( vEventBitSettingTask) get the chance to read the bits. In other reader tasks(vEventBitSettingTask1 and vEventBitSettingTask2), the value resultant event group value was 0.
Here to get the chance to all reader tasks which waited for one of the bit to set, I changed the value of xClearOnExit to following value
vEventBitSettingTask - xClearOnExit-pdFALSE
vEventBitSettingTask 1- xClearOnExit-pdFALSE
vEventBitSettingTask2 - xClearOnExit-pdTRUE
In that case, i get the following output,
bit 0 -vEventBitReadingTask - first reader output string
bit 0 -vEventBitReadingTask
bit 0 -vEventBitReadingTask
bit 0-vEventBitReadingTask1-second reader output string
bit 0-vEventBitReadingTask1
bit 0-vEventBitReadingTask1
bit 0-vEventBitReadingTask2-third reader output string
Is this the correct way to do? for all reader tasks get the chance to read the set bit / any other way to attain this?
Attached the code for reference.