Search found 10 matches
- Thu Sep 22, 2016 7:11 am
- Forum: Development of MicroPython
- Topic: Eliminate all global state
- Replies: 16
- Views: 13944
Re: RE: Re: Eliminate all global state
The linux kernel allocates 4K (or 8K) stacks aligned on a 4K (or 8K) boundary. At one end of the stack (I don't recall which end off the top of my head), the kernel keeps a structure for the thread, which contains information specific to that thread. You can locate that structure by simply taking t...
- Thu Sep 22, 2016 6:28 am
- Forum: Development of MicroPython
- Topic: Eliminate all global state
- Replies: 16
- Views: 13944
Re: RE: Re: Eliminate all global state
I think it depends on how the TLS is implemented. One way is to simply have a global pointer which is "thread context" and the context switcher updates it as it does context switches. The linux kernel uses aligned stacks and then just masks the stack pointer to get the TLS pointer. Neither of those...
- Wed Sep 21, 2016 10:31 pm
- Forum: Development of MicroPython
- Topic: Eliminate all global state
- Replies: 16
- Views: 13944
Re: RE: Re: Eliminate all global state
Sure just have the 2 threads that belong "together" have pointers to the same context data. As to passing around all of the context data, you'd need to try it and see what type of memory/performance penalty you'd pay. Similarly wouldn't there be a performance penalty for using thread local storage?...
- Wed Sep 21, 2016 10:20 pm
- Forum: Development of MicroPython
- Topic: Eliminate all global state
- Replies: 16
- Views: 13944
Re: Eliminate all global state
But then if you wanted to share the same interpretter across two threads you couldn't. Say if you wanted two interpreters that ran in isolation, then you wanted to take advantage of some of that new threading code in there and have those two threads fire up some threads whose state you wanted to sha...
- Wed Sep 21, 2016 7:26 pm
- Forum: Development of MicroPython
- Topic: Eliminate all global state
- Replies: 16
- Views: 13944
Re: Eliminate all global state
Looks like you do have GIL as well, but if there can be one per interpreter then it's still fine.
- Wed Sep 21, 2016 7:19 pm
- Forum: Development of MicroPython
- Topic: Eliminate all global state
- Replies: 16
- Views: 13944
Re: Eliminate all global state
Looks like you've also got this 'mp_dynamic_compiler', which I guess would need to be moved out too. And mp_module___main__ which I guess is the '__main__' module.
- Wed Sep 21, 2016 7:11 pm
- Forum: Development of MicroPython
- Topic: Eliminate all global state
- Replies: 16
- Views: 13944
Re: Eliminate all global state
Hi Dave. That's awesome that you already have it all in that 'mp_state_ctx' struct. git grep tells me there's a little under 300 references to the 'MP_STATE_CTX', 'MP_STATE_VM' and 'MP_STATE_MEM'. I think it's just a case of ripping those out and passing the mp_state_ctx through to all the functions...
- Wed Sep 21, 2016 7:16 am
- Forum: Development of MicroPython
- Topic: Eliminate all global state
- Replies: 16
- Views: 13944
Re: Eliminate all global state
Hey thanks for this. I'm mainly interested in having two completely independent instances of the interpreter running in separate threads managed by my application. Hence the questions about GIL and global variables. Probably the best bet is for me to trawl the forumn more and have a dig through the ...
- Wed Sep 21, 2016 6:06 am
- Forum: Development of MicroPython
- Topic: Eliminate all global state
- Replies: 16
- Views: 13944
Re: Eliminate all global state
I had a quick look through the source code and can see that there is still use of global variables. Does micropython have a GIL like CPython ?
- Tue Sep 20, 2016 10:44 pm
- Forum: Development of MicroPython
- Topic: Eliminate all global state
- Replies: 16
- Views: 13944
Eliminate all global state
Hey, I work in the Animation/VFX as as software developer. I've been looking around for a scripting language I can embed in a hobby 3d tool I'm writing. Python is the industry standard scripting language for VFX at the moment, and is embedded into most tools and pipelines, but the abundant use of gl...