<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/supervisor/shared/tick.h, branch 5.3.x</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=5.3.x</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=5.3.x'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2019-11-20T20:37:13+00:00</updated>
<entry>
<title>supervisor: tick: add supervisor_fake_tick</title>
<updated>2019-11-20T20:37:13+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@gmail.com</email>
</author>
<published>2019-11-20T16:15:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=46c5775ba4b9c4905f8e3f4c1842c2c6c04d8fb0'/>
<id>urn:sha1:46c5775ba4b9c4905f8e3f4c1842c2c6c04d8fb0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>supervisor: tick: document</title>
<updated>2019-11-20T20:37:13+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@gmail.com</email>
</author>
<published>2019-11-20T16:15:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=a9baa0f954ec757ef1e3990af136a4f0b3cb2b1e'/>
<id>urn:sha1:a9baa0f954ec757ef1e3990af136a4f0b3cb2b1e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>supervisor: tick: Rewrite without atomics</title>
<updated>2019-11-20T20:37:13+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@gmail.com</email>
</author>
<published>2019-11-20T16:15:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=70719597ab7b3785a6641b08ef3cb82d9b6b459b'/>
<id>urn:sha1:70719597ab7b3785a6641b08ef3cb82d9b6b459b</id>
<content type='text'>
</content>
</entry>
<entry>
<title>run_background_tasks: Do nothing unless there has been a tick</title>
<updated>2019-11-18T17:26:48+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@gmail.com</email>
</author>
<published>2019-11-18T15:53:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=568636d562b4c64d0095ff2ac921b79eb69e520d'/>
<id>urn:sha1:568636d562b4c64d0095ff2ac921b79eb69e520d</id>
<content type='text'>
This improves performance of running python code by 34%, based
on the "pystone" benchmark on metro m4 express at 5000 passes
(1127.65 -&gt; 1521.6 passes/second).

In addition, by instrumenting the tick function and monitoring on an
oscilloscope, the time actually spent in run_background_tasks() on
the metro m4 decreases from average 43% to 0.5%. (however, there's
some additional overhead that is moved around and not accounted for
in that "0.5%" figure, each time supervisor_run_background_tasks_if_tick
is called but no tick has occurred)

On the CPB, it increases pystone from 633 to 769, a smaller percentage
increase of 21%.  I did not measure the time actually spent in
run_background_tasks() on CPB.

Testing performed: on metro m4 and cpb, run pystone adapted from python3.4
(change time.time to time.monotonic for sub-second resolution)

Besides running a 5000 pass test, I also ran a 50-pass test while
scoping how long an output pin was set.  Average: 34.59ms or 1445/s on m4,
67.61ms or 739/s on cbp, both matching the other pystone result reasonably
well.

import pystone
import board
import digitalio
import time

d = digitalio.DigitalInOut(board.D13)
d.direction = digitalio.Direction.OUTPUT

while True:
    d.value = 0
    time.sleep(.01)
    d.value = 1
    pystone.main(50)
</content>
</entry>
<entry>
<title>Supervisor: move most of systick to the supervisor</title>
<updated>2019-11-18T17:01:23+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@gmail.com</email>
</author>
<published>2019-11-18T14:22:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=7f744a2369a5036cadfa05575da1704f709c98bb'/>
<id>urn:sha1:7f744a2369a5036cadfa05575da1704f709c98bb</id>
<content type='text'>
This code is shared by most parts, except where not all the #ifdefs
inside the tick function were present in all ports.  This mostly would
have broken gamepad tick support on non-samd ports.

The "ms32" and "ms64" variants of the tick functions are introduced
because there is no 64-bit atomic read.  Disabling interrupts avoids
a low probability bug where milliseconds could be off by ~49.5 days
once every ~49.5 days (2^32 ms).

Avoiding disabling interrupts when only the low 32 bits are needed is a minor
optimization.

Testing performed: on metro m4 express, USB still works and
time.monotonic_ns() still counts up
</content>
</entry>
</feed>
