summaryrefslogtreecommitdiffstatshomepage
path: root/py/mpstate.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-02-16 18:05:06 +1100
committerDamien George <damien.p.george@gmail.com>2017-03-20 15:20:26 +1100
commit6e74d24f30bca3fb70876b1fb9a6b3a59850b83c (patch)
tree391a713749edac08db0efc45e6ff987b2f437dc0 /py/mpstate.h
parentbf29fe2e138a30688cfb94ad3859f903f935ced1 (diff)
downloadmicropython-6e74d24f30bca3fb70876b1fb9a6b3a59850b83c.tar.gz
micropython-6e74d24f30bca3fb70876b1fb9a6b3a59850b83c.zip
py: Add micropython.schedule() function and associated runtime code.
Diffstat (limited to 'py/mpstate.h')
-rw-r--r--py/mpstate.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/py/mpstate.h b/py/mpstate.h
index 9e4f54ae5b..29f93870a8 100644
--- a/py/mpstate.h
+++ b/py/mpstate.h
@@ -50,6 +50,16 @@ typedef struct mp_dynamic_compiler_t {
extern mp_dynamic_compiler_t mp_dynamic_compiler;
#endif
+// These are the values for sched_state
+#define MP_SCHED_IDLE (1)
+#define MP_SCHED_LOCKED (-1)
+#define MP_SCHED_PENDING (0) // 0 so it's a quick check in the VM
+
+typedef struct _mp_sched_item_t {
+ mp_obj_t func;
+ mp_obj_t arg;
+} mp_sched_item_t;
+
// This structure hold information about the memory allocation system.
typedef struct _mp_state_mem_t {
#if MICROPY_MEM_STATS
@@ -129,6 +139,12 @@ typedef struct _mp_state_vm_t {
// pending exception object (MP_OBJ_NULL if not pending)
volatile mp_obj_t mp_pending_exception;
+ #if MICROPY_ENABLE_SCHEDULER
+ volatile int16_t sched_state;
+ uint16_t sched_sp;
+ mp_sched_item_t sched_stack[MICROPY_SCHEDULER_DEPTH];
+ #endif
+
// current exception being handled, for sys.exc_info()
#if MICROPY_PY_SYS_EXC_INFO
mp_obj_base_t *cur_exception;