Threading Module for Windows build

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
EqBooster
Posts: 9
Joined: Mon Jul 16, 2018 11:21 am

Threading Module for Windows build

Post by EqBooster » Thu Jul 26, 2018 7:47 am

Hello guys,

I would really need the threading module for the Windows build. Is this possible already? I found it in the Unix build, and i know that somehow the windows build uses unix.

Sorry if this question is dumb, but i dont know what to do :) .

stijn
Posts: 321
Joined: Thu Apr 24, 2014 9:13 am

Re: Threading Module for Windows build

Post by stijn » Thu Jul 26, 2018 8:10 am

This isn't implemented yet. The windows ports (mingw-w64 or msvc) indeed use some of the unix port's files but the threading code isn't one of those: I looked into that once and since it uses posix threading, for the msvc port this would mean either using an external win32<->posix thread library or writing it from scratch. As I didn't have any use for threading at the time it was introduced in uPy I only quickly tried the first option but that took a couple of tries, none of them succesful, so I just gave up. However possibly for mingw-w64 it just works as-is by adding the source to the makefile and setting an option in mpconfigport.h. Which port are you using?

EqBooster
Posts: 9
Joined: Mon Jul 16, 2018 11:21 am

Re: Threading Module for Windows build

Post by EqBooster » Thu Jul 26, 2018 8:15 am

Ohh ok, thanks for your response..

I am currently doing my bachelor thesis and my goal is to wrap a can-stack library written in C. The thing is it is important that the build also runs on windows so i guess i can't use micropython to do this in that case, because threading is required.
The build for Embedded Systems would have just been a "nice to have"...

I guess the best solution would be to make 2 versions then, one for windows and later when needed for micropython. That's a bit sad for me because i really started liking this project. Maybe i can use it the next time when i make something :)
I understand that the main focus of this project is to support microcontrollers of course :)

I tried to add the sources to the Makefile but I didn't get it working...

stijn
Posts: 321
Joined: Thu Apr 24, 2014 9:13 am

Re: Threading Module for Windows build

Post by stijn » Thu Jul 26, 2018 8:54 am

Yeah I also just tried adding mpthreadport.c to the Makefile, copied mpthreadort.h to the windows directory but no go: mingw doesn't have siginfo_t and the likes.
Looking at mpthreadport.c however it doesn't seem too hard to create a similar file which works with win32 threads/mutexes. There's not really a win32 equivalent for signals but that shouldn't matter, I think it's ok for mp_thread_gc_others to just loop over the other threads and gc_collect_root on them (that's also what e.g. the stm32 port does). I understand you're working on your thesis so you have other things to do, but should you have time left you could always have a go at porting it :)

EqBooster
Posts: 9
Joined: Mon Jul 16, 2018 11:21 am

Re: Threading Module for Windows build

Post by EqBooster » Fri Jul 27, 2018 5:26 am

Well i guess i have to let this approach then because i don't get it working. It's sad that the windows-build is required for me. The port for the STM32 and i guess other microcontrollers is amazing already :)

Post Reply