Support for threading in Frosted OS

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
danielinux
Posts: 3
Joined: Fri May 19, 2017 6:31 am

Support for threading in Frosted OS

Post by danielinux » Fri May 19, 2017 7:24 am

Hello,

in my port for Frosted embedded OS, I want to add support for the threading module.

Frosted is basically a small unix for ARM Cortex-M, but we had to make major changes to make the unix port more "embedded" (stack size etc.)

The low-level _thread module is already working properly.
What is the best way to do this? Should that be written in python in my scripts/ directory, or should I provide a kind of "uthreading" module in C first?

Does a python implementation of thrading on top of _thread exist anywhere?
And otherwise, would it be interesting if I provide a up module written in C which can also be directly imported in your unix/ port?

More info:
https://github.com/insane-adding-machines/frosted
https://github.com/insane-adding-machines/micropython

Thanks
/d

danielinux
Posts: 3
Joined: Fri May 19, 2017 6:31 am

Re: Support for threading in Frosted OS

Post by danielinux » Sat May 20, 2017 12:03 pm

I found out that cpython implement the threading module on top of _thread like this:

https://github.com/python/cpython/blob/ ... reading.py

Would it be possible/make sense to port the threading.py from Cpython into my scripts/ dir? Are there license limitations?

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Support for threading in Frosted OS

Post by pfalcon » Sat May 20, 2017 12:23 pm

A "zen" of MicroPython is "We write MicroPython in C to write less code in C". See more about MicroPython "zen" here: https://github.com/micropython/micropyt ... Guidelines .

So, writing code in C doesn't make sense, unless there're very good reasons to write code in C.
Would it be possible/make sense to port the threading.py from Cpython into my scripts/ dir? Are there license limitations?
You will need to find it it out whether it makes sense or not. You can take micropython-lib project as an example, it consists of dozens of modules, each originated in different ways: a) taken from CPython as is (or with trivial changes); b) ported from CPython; c) developed specifically for MicroPython; d) not developed (yet) at all.

The code originated from CPython of course has CPython license. The main MicroPython repository comes under single MIT license, so no CPython code can be imported there.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

danielinux
Posts: 3
Joined: Fri May 19, 2017 6:31 am

Re: Support for threading in Frosted OS

Post by danielinux » Sat May 20, 2017 1:59 pm

This is all very informative. I will indeed opt for a port of threading.py from Cpython, also looking to add it to micropython-lib.

We are trying to keep our Frosted fork mergeable, if at some point it shall be the right time to consider https://github.com/micropython/micropython/pull/2634 for reviews or a merge. I will keep working to improve it, but we are already excited we got to the point to run multi-threaded python applications on our targets.

Thank you for the support!

Post Reply