I'm currently facing a fairly interesting problem with the garbage collection when running the micropython kernel inside of an RTOS.
as micropython runs inside of an RTOS, I'm making use of GC_ENTER and GC_EXIT to lock & unlock mutexes.
I'm wondering now if this is due to something I did in my port, or if this is an issue that exists within the standard micropython builds too?
Has anyone else seen this behavior, or am I missing something / did I make a mistake when implementing an alternative filesystem?
I started from MicroPython 1.9.3
Scenario:
Code: Select all
call gc_alloc()
GC_ENTER()
...
GC_EXIT()
call gc_collect()
call gc_collect_start()
GC_ENTER()
call gc_collect_end()
call gc_sweep()
call "__del__" method of object if it exists (in this example an old file pointer)
file_close() throws a "file not open" OS Exception
OS Exception calls gc_alloc()
gc_alloc() calls GC_ENTER()
Result: The thread waits for the mutex to be released by itself.