<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>mutual exclusion between ISR and a RTX Thread</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/38674/mutual-exclusion-between-isr-and-a-rtx-thread</link><description> 
I need to share a data structure used by a RTX Thread and and ISR.
Its basically a circular queue for the serial port. Now the options
that I am aware of are to either use isr_mbx_send() to post messages
or else use isr_sem_send. But both the options</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: mutual exclusion between ISR and a RTX Thread</title><link>https://community.arm.com/thread/78042?ContentTypeID=1</link><pubDate>Fri, 15 Jan 2010 09:14:16 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b01a5941-b7af-46f3-b53f-c59edc40a558</guid><dc:creator>Phani Giddi</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks for the reply.&lt;/p&gt;

&lt;p&gt;
I think you are right since the reader and writer are the owners
of their respective pointers it doesnt matter a lot if one reads
while the other is performing in the middle of performing a write (
hope fully it will be atomic ).&lt;/p&gt;

&lt;p&gt;
As you have suggested I will still use of the mechanisms to send
an event to the task so that it wakes up.&lt;/p&gt;

&lt;p&gt;
-Phani&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: mutual exclusion between ISR and a RTX Thread</title><link>https://community.arm.com/thread/57588?ContentTypeID=1</link><pubDate>Fri, 15 Jan 2010 08:38:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e144c798-093e-4315-8a2b-84e8228690fb</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Just sharing a traditional round-robin buffer doesn&amp;#39;t require you
to lock any scheduling or similar, as long as the processor is
capable of reading and writing the head and tail pointers
atomically.&lt;/p&gt;

&lt;p&gt;
The reader is owner of one of the pointers - where to fetch data.
The writer is owner of the other pointer - where to put new data.&lt;/p&gt;

&lt;p&gt;
A task switch or interrupt in the middle of a read/modify/write
will not be dangerous. The worst case is that the reader has picked
up an entry without having had time to inform the writer - so the
writer may sometimes see a one-entry smaller buffer. Or the writer
may have inserted one more entry, without having time to update the
write pointer, so the reader may see one pending entry to little.&lt;/p&gt;

&lt;p&gt;
But whatever you do, you must at least let the ISR send an event
to the reader, so that the scheduler may perform a task-switch to
pick up the received data (in case the reader have enough priority in
relation to the currently active thread).&lt;/p&gt;

&lt;p&gt;
Whatever you do, you will not manage without at least some
overhad, since without any overhead, the scheduler will not be able
to know if it should perform a task switch to activate the
reader.&lt;/p&gt;

&lt;p&gt;
If you have a large queue, and no timing requirements, and know
that the reader will round-robin-schedule often enough to be able to
poll the receive queue for data, then you can manage without
informing the scheduler. But the polling of the queue is of course
also a form of overhead - and requires a task switch just to let the
the task poll the queue.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>