File tree Expand file tree Collapse file tree 4 files changed +21
-1
lines changed
Expand file tree Collapse file tree 4 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 2727
2828#include <assert.h>
2929#include <stdio.h>
30+ #include <stdlib.h>
3031#include <string.h>
3132
3233#include "py/gc.h"
3334#include "py/runtime.h"
35+ #include "py/mpthread.h"
36+ #include "py/mphal.h"
3437
3538#if MICROPY_DEBUG_VALGRIND
3639#include <valgrind/memcheck.h>
@@ -214,7 +217,9 @@ void gc_init(void *start, void *end) {
214217 #endif
215218
216219 // unlock the GC
220+ #if MICROPY_PY_THREAD
217221 MP_STATE_THREAD (gc_lock_depth ) = 0 ;
222+ #endif
218223
219224 // allow auto collection
220225 MP_STATE_MEM (gc_auto_collect_enabled ) = 1 ;
Original file line number Diff line number Diff line change @@ -169,7 +169,6 @@ static void *thread_entry(void *args_in) {
169169
170170 MP_THREAD_GIL_ENTER ();
171171
172- // signal that we are set up and running
173172 mp_thread_start ();
174173
175174 // TODO set more thread-specific state here:
@@ -196,7 +195,11 @@ static void *thread_entry(void *args_in) {
196195 }
197196 }
198197
198+ #if !MICROPY_ZEPHYR_THREADING
199199 DEBUG_printf ("[thread] finish ts=%p\n" , & ts );
200+ #else
201+ DEBUG_printf ("[thread] finish\n" );
202+ #endif
200203
201204 // signal that we are finished
202205 mp_thread_finish ();
Original file line number Diff line number Diff line change @@ -58,11 +58,20 @@ void mp_thread_recursive_mutex_unlock(mp_thread_recursive_mutex_t *mutex);
5858
5959#if MICROPY_PY_THREAD && MICROPY_PY_THREAD_GIL
6060#include "py/mpstate.h"
61+ // Allow ports to override GIL macros (e.g., to add k_yield() for cooperative scheduling)
62+ #ifndef MP_THREAD_GIL_ENTER
6163#define MP_THREAD_GIL_ENTER () mp_thread_mutex_lock(&MP_STATE_VM(gil_mutex), 1)
64+ #endif
65+ #ifndef MP_THREAD_GIL_EXIT
6266#define MP_THREAD_GIL_EXIT () mp_thread_mutex_unlock(&MP_STATE_VM(gil_mutex))
67+ #endif
6368#else
69+ #ifndef MP_THREAD_GIL_ENTER
6470#define MP_THREAD_GIL_ENTER ()
71+ #endif
72+ #ifndef MP_THREAD_GIL_EXIT
6573#define MP_THREAD_GIL_EXIT ()
6674#endif
75+ #endif
6776
6877#endif // MICROPY_INCLUDED_PY_MPTHREAD_H
Original file line number Diff line number Diff line change @@ -76,3 +76,6 @@ Q(/rom/lib)
7676#if MICROPY_ENABLE_PYSTACK
7777Q (pystack exhausted )
7878#endif
79+
80+ // Special methods
81+ Q (__del__ )
You can’t perform that action at this time.
0 commit comments