YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Acorns: C++ wrapper as an Arduino ESP32 lib, with task management and REPL
EternityForest
#1 Posted : Thursday, August 23, 2018 4:30:36 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/10/2018(UTC)
Posts: 2
Location: Seattle

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Just started working on this, but there's already quite a bit there. You can load multiple named "programs", there's GIL based preemptive threading, bindings to the Arduino hardware, the serial port has a REPL,
there's easy functions for adding variables.

The way I'm doing "programs" is there's a hidden root app, and all the root tables of your loaded programs have the root interpreter as a delegate. I patched Squirrel itself to let you force close tasks by throwing
exceptions, and setting a flag that disables handling them.

My goal here is to make the bindings really bulletproof, so you don't need to worry about race conditions or memory leaks. I've even got functions to accept a callback from Squirrel and to run a cleanup function should Squirrel ever delete the subscription object.

Before patching, Squirrel seems to run a simple variable incrementing loop at 300KHz, so performance should be good enough to write a game engine in if someone had the time.

https://github.com/EternityForest/Acorns
absence
#2 Posted : Thursday, August 30, 2018 9:57:59 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 8/23/2014(UTC)
Posts: 124
Man
Location: Northern Germany & Lincolnshire, U.K.

Thanks: 1 times
Was thanked: 10 time(s) in 10 post(s)
erm... sorry. I can't track your patches and am too lazy to download and diff :)
However, I can't find mulitthreading relevant stuff where I'd put it myself (sqvm::execute)...
If you did nothing about multithreading issues, you're going to hit the wall. Been there, done that (and solved it :D)
EternityForest
#3 Posted : Friday, September 7, 2018 5:22:43 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/10/2018(UTC)
Posts: 2
Location: Seattle

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
I do in fact have multithreading in sqvm::execute!

Code:
  sqsuspendcountdown --;
            if(sqsuspendcountdown==0)
            {   
                sqsuspendcountdown = SQ_SUSPEND_INTERVAL;
                sq_threadyield();
                if(stopRequestedFlag)
                {
                    //This kind of exception we don't handle
                    allowHandleException = false;
                    Raise_Error("Execution stopped via API call"); SQ_THROW(); continue;
                }
            }


sq_threadyield() is a weak function that does nothing in Squirrel itself, and Acorns has it releasing and then grabbing the GIL(But that function isn't part of the public API). It's just using FreeRTOS threads
for everything, but they are in a thread pool, so you can reuse them between programs.

I kinda wish Squirrel had native support for this kind of GIL-oriented stuff, but I'd rather make a tiny patch than deal with something locked to one OS.

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.095 seconds.