Am 02.03.2014 um 15:21 schrieb John Kasunich <[email protected]>:
> There are several variables that are used to communicate
> between the two parts. The faster part was written assuming
> that those variables would not change during any single
> execution of the code. Allowing the slower thread to have a
> higher priority (and thus to interrupt) the faster thread would
> break that assumption.
I have read up on the data flow in stepgen.c and I found the following for
normal (i.e. not disabled, and setup disregarded):
make_pulses reads:
stepgen->accum
stepgen->target_addval
stepgen->deltalim
make_pulses writes:
stepgen->accum
update_freq reads:
stepgen->accum
update_freq writes:
stepgen->target_addval
stepgen->deltalim
Now stepgen->accum can be taken out of the picture for considering transactions
since that is the single scalar value read back by update_freq (it could be
replaced by an atomic 64bit fetch which is supported on all architectures, but
that is a side issue).
The interesting case are the two values which update_freq writes. I assume you
are referring to those?
I can see how scheduling comes in here the way this is coded, but I think this
is basically a complicated way to achieve an atomic message transmit from
update_freq to make_pulses.
Assume there were a way to send records from update_freq to make_pulses in an
atomic fashion, and such an update record contains stepgen->target_addval, and
stepgen->deltalim. make_pulses would check if a new record is available; if so,
consume it and base the current calculation on the values contained therein. If
not, it would use the values recorded from the previous update message, and
proceed alike.
In that case it would become meaningless what threads do in relation to each
other, since the result cannot be influenced by that.
Note "Assume there were a way" is already present in entirety, it is Pavel's
ringbuffer code which does exactly that, see below.
This is my hypothesis:
we can replace thread interaction of compound values like above by
ringbuffer communications, and can forget about this scheduling rate and
priority business altogether.
Can anybody falsify this hypothesis, and how? Really interested.
- Michael
the ringbuffer code is here:
http://git.linuxcnc.org/gitweb?p=linuxcnc.git;a=blob;f=src/rtapi/ring.h;h=874c7793fe2d00c1c8002f2a04b1c742e785c02d;hb=refs/heads/unified-build-candidate-3#l266
The required operations are:
record_write_begin() - allocate space for a message in the rb but do not commit
the write yet
record_write_end() - commit the write operation
record_next_size() - check data available and operate on same
record_shift() - consume the record.
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers