<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Atomics</title><link>https://sourceforge.net/p/sdcc/wiki/Atomics/</link><description>Recent changes to Atomics</description><atom:link href="https://sourceforge.net/p/sdcc/wiki/Atomics/feed" rel="self"/><language>en</language><lastBuildDate>Thu, 31 Oct 2024 08:37:33 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/sdcc/wiki/Atomics/feed" rel="self" type="application/rss+xml"/><item><title>Atomics modified by Philipp Klaus Krause</title><link>https://sourceforge.net/p/sdcc/wiki/Atomics/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -9,9 +9,10 @@
 For many targets, SDCC currently uses different representations, typically because it would be impossible or inefficient to use 0 for reset and 1 for set.
 Most targets do not have a dedicated test-and-set instruction. For those, we usually use a right-shift with indirect addressing instead, forcing different representations.
 For tlcs90, there is `tset`, but the shift is more efficient. For the Rabbits, `bit b, (hl)` is a privileged instruction, which makes `bit b, (hl) set b(hl)` an atomic test-and-set, but again, the shift is more efficient.
-For mcs51 / ds390, `xch` is used, which only can reach part of the address space, so atomic_flag on ms51 and ds390 is possible only in some named address spaces.
 For f8 `xch` is used.
+For mcs51 / ds390, we use an atomic_exchange implemented via restartable sequences.
+

 Other atomics
 --
-Not yet supported.
+Not yet supported. For a single hardware thread, they could be implemented based on restartable sequences (already supported in the backend for mcs51 / ds390 and used for atomic_flag).
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Philipp Klaus Krause</dc:creator><pubDate>Thu, 31 Oct 2024 08:37:33 -0000</pubDate><guid>https://sourceforge.netcf66c3f3593f57cd259b295baf35f7f31c7b9676</guid></item><item><title>Atomics modified by Philipp Klaus Krause</title><link>https://sourceforge.net/p/sdcc/wiki/Atomics/</link><description>&lt;div class="markdown_content"&gt;&lt;h2 id="volatile-sig_atomic_t"&gt;volatile sig_atomic_t&lt;/h2&gt;
&lt;p&gt;The type for which the C standard guarantees that it can be accessed as atomic entitiy, even in the presence of signals (interrupts).&lt;br/&gt;
SDCC makes sig_atomic_t an unsiged char, i.e. a single byte. As long as volatile is implemented correctly, this should fulfill the C standard's requirements of reads and writes being atomic. No lock is required.&lt;/p&gt;
&lt;h2 id="atomic_flag"&gt;atomic_flag&lt;/h2&gt;
&lt;p&gt;C requires this to be a "lock-free" atomic type. Currently the representations of the set and reset states are not fixed in the C standard. But many programmers expect reset to be 0 and set to be 1.&lt;br/&gt;
For many targets, SDCC currently uses different representations, typically because it would be impossible or inefficient to use 0 for reset and 1 for set.&lt;br/&gt;
Most targets do not have a dedicated test-and-set instruction. For those, we usually use a right-shift with indirect addressing instead, forcing different representations.&lt;br/&gt;
For tlcs90, there is &lt;code&gt;tset&lt;/code&gt;, but the shift is more efficient. For the Rabbits, &lt;code&gt;bit b, (hl)&lt;/code&gt; is a privileged instruction, which makes &lt;code&gt;bit b, (hl) set b(hl)&lt;/code&gt; an atomic test-and-set, but again, the shift is more efficient.&lt;br/&gt;
For mcs51 / ds390, &lt;code&gt;xch&lt;/code&gt; is used, which only can reach part of the address space, so atomic_flag on ms51 and ds390 is possible only in some named address spaces.&lt;br/&gt;
For f8 &lt;code&gt;xch&lt;/code&gt; is used.&lt;/p&gt;
&lt;h2 id="other-atomics"&gt;Other atomics&lt;/h2&gt;
&lt;p&gt;Not yet supported.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Philipp Klaus Krause</dc:creator><pubDate>Fri, 22 Sep 2023 08:44:15 -0000</pubDate><guid>https://sourceforge.netc83e64733e5736edb29a94a8e9d217f5c16bb085</guid></item></channel></rss>