python-on-a-chip online compiler

Dependencies:   mbed TSI

/media/uploads/va009039/p14p-f446re.png

more info: python-on-a-chip

Committer:
va009039
Date:
Thu Apr 14 22:32:57 2016 +0000
Revision:
15:94ca5c8003e5
Parent:
0:65f1469d6bfb
update Nucleo-F401RE.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 0:65f1469d6bfb 1 /*
va009039 0:65f1469d6bfb 2 # This file is Copyright 2007 Dean Hall.
va009039 0:65f1469d6bfb 3 # This file is part of the PyMite VM.
va009039 0:65f1469d6bfb 4 # This file is licensed under the MIT License.
va009039 0:65f1469d6bfb 5 # See the LICENSE file for details.
va009039 0:65f1469d6bfb 6 */
va009039 0:65f1469d6bfb 7
va009039 0:65f1469d6bfb 8
va009039 0:65f1469d6bfb 9 #ifndef __THREAD_H__
va009039 0:65f1469d6bfb 10 #define __THREAD_H__
va009039 0:65f1469d6bfb 11
va009039 0:65f1469d6bfb 12
va009039 0:65f1469d6bfb 13 /**
va009039 0:65f1469d6bfb 14 * \file
va009039 0:65f1469d6bfb 15 * \brief VM Thread
va009039 0:65f1469d6bfb 16 *
va009039 0:65f1469d6bfb 17 * Encapsulating a frame pointer, a root code object and thread state.
va009039 0:65f1469d6bfb 18 */
va009039 0:65f1469d6bfb 19
va009039 0:65f1469d6bfb 20
va009039 0:65f1469d6bfb 21 #include "interp.h"
va009039 0:65f1469d6bfb 22
va009039 0:65f1469d6bfb 23
va009039 0:65f1469d6bfb 24 /** Frequency in Hz to switch threads */
va009039 0:65f1469d6bfb 25 #define THREAD_RESCHEDULE_FREQUENCY 10
va009039 0:65f1469d6bfb 26
va009039 0:65f1469d6bfb 27
va009039 0:65f1469d6bfb 28 /**
va009039 0:65f1469d6bfb 29 * Interpreter return values
va009039 0:65f1469d6bfb 30 *
va009039 0:65f1469d6bfb 31 * Used to control interpreter loop
va009039 0:65f1469d6bfb 32 * and indicate return value.
va009039 0:65f1469d6bfb 33 * Negative values indicate erroneous results.
va009039 0:65f1469d6bfb 34 * Positive values indicate "continue interpreting",
va009039 0:65f1469d6bfb 35 * but first do something special like reschedule threads
va009039 0:65f1469d6bfb 36 * or (TBD) sweep the heap.
va009039 0:65f1469d6bfb 37 */
va009039 0:65f1469d6bfb 38 typedef enum PmInterpCtrl_e
va009039 0:65f1469d6bfb 39 {
va009039 0:65f1469d6bfb 40 /* other erroneous exits go here with negative values */
va009039 0:65f1469d6bfb 41 INTERP_CTRL_ERR = -1, /**< Generic error causes exit */
va009039 0:65f1469d6bfb 42 INTERP_CTRL_EXIT = 0, /**< Normal execution exit */
va009039 0:65f1469d6bfb 43 INTERP_CTRL_CONT = 1, /**< Continue interpreting */
va009039 0:65f1469d6bfb 44 INTERP_CTRL_RESCHED = 2 /**< Reschedule threads */
va009039 0:65f1469d6bfb 45 /* all positive values indicate "continue interpreting" */
va009039 0:65f1469d6bfb 46 } PmInterpCtrl_t, *pPmInterpCtrl_t;
va009039 0:65f1469d6bfb 47
va009039 0:65f1469d6bfb 48 /**
va009039 0:65f1469d6bfb 49 * Thread obj
va009039 0:65f1469d6bfb 50 *
va009039 0:65f1469d6bfb 51 */
va009039 0:65f1469d6bfb 52 typedef struct PmThread_s
va009039 0:65f1469d6bfb 53 {
va009039 0:65f1469d6bfb 54 /** object descriptor */
va009039 0:65f1469d6bfb 55 PmObjDesc_t od;
va009039 0:65f1469d6bfb 56
va009039 0:65f1469d6bfb 57 /** current frame pointer */
va009039 0:65f1469d6bfb 58 pPmFrame_t pframe;
va009039 0:65f1469d6bfb 59
va009039 0:65f1469d6bfb 60 /**
va009039 0:65f1469d6bfb 61 * Interpreter loop control value
va009039 0:65f1469d6bfb 62 *
va009039 0:65f1469d6bfb 63 * A positive value means continue interpreting.
va009039 0:65f1469d6bfb 64 * A zero value means normal interpreter exit.
va009039 0:65f1469d6bfb 65 * A negative value signals an error exit.
va009039 0:65f1469d6bfb 66 */
va009039 0:65f1469d6bfb 67 PmInterpCtrl_t interpctrl;
va009039 0:65f1469d6bfb 68 } PmThread_t,
va009039 0:65f1469d6bfb 69 *pPmThread_t;
va009039 0:65f1469d6bfb 70
va009039 0:65f1469d6bfb 71
va009039 0:65f1469d6bfb 72 /**
va009039 0:65f1469d6bfb 73 * Constructs a thread for a root frame.
va009039 0:65f1469d6bfb 74 *
va009039 0:65f1469d6bfb 75 * @param pframe Frame object as a basis for this thread.
va009039 0:65f1469d6bfb 76 * @param r_pobj Return by reference; Ptr to the newly created thread object.
va009039 0:65f1469d6bfb 77 * @return Return status
va009039 0:65f1469d6bfb 78 */
va009039 0:65f1469d6bfb 79 PmReturn_t thread_new(pPmObj_t pframe, pPmObj_t *r_pobj);
va009039 0:65f1469d6bfb 80
va009039 0:65f1469d6bfb 81 #endif /* __THREAD_H__ */