You are right, think the sampler, sampler_usr solved this properly. The simple Micro controllers I usually use is single core and no instruction reordering.
Software is usally also low complexity, instruction for atomic write and check might however be available, operating systems are available if needed and/but hardware interrupt is usually the choice because task i triggered byt hardware, it is very common to trigger task execution from PWM timer which make the interrupt handler a really good choice for the task then interrupt with priority is available. > There is a LOT more to this. > > 1. Dual or multi-core CPUs add some complexity because all the CPUs share a > common memory. What if all four CPUs try to run the "test and set" at the > same time? Also, you can no longer assume an interrupt handler has > exclusive use of memory. > 2. what if the process uses two queues? Process A might hold access to > Queue X and process B holds Y and then each waits for the other process to > release the other queue and the system deadlocks. > 3. what if there are more than two processes? How to ensure that access to > the queue is fairly sharded between four or six users? > 4. What if the CPU you are using lacks a test and set instruction? > > There are good solutions but today NO ONE has to solve these problems > solutions were worked out 50 years ago. > > On Sat, Jul 27, 2019 at 10:22 AM John Dammeyer <jo...@autoartisans.com> > wrote: > ... > > > > ... > > > > I sometimes use similar scheme on Micro controller, read pointer > > chasing > > > a > > > > write pointer. For atomicity I use read modify write of variable from > > one > > > > process only and assumed read/write of variable is atomic and as I use > > > > interrupts with priority I also know one process may interrupt the > > other > > > > but not the opposite so I have been able to get by without disabling > > > > interrupt. Reading process will always get either new or old value. > > > > > > > > Sampler, halsampler seems to work great though I get some problem with > > > > overrun though a single missed value sometimes does not matter to > > > much. I > > > > think halsampler use a similar method, read pointer chasing a write > > > > pointer. In case of full FIFO old value are overwritten which works > > great. _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users