Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
thread.h
00001 /* 00002 # This file is Copyright 2007, 2009 Dean Hall. 00003 # 00004 # This file is part of the PyMite VM. 00005 # The PyMite VM is free software: you can redistribute it and/or modify 00006 # it under the terms of the GNU GENERAL PUBLIC LICENSE Version 2. 00007 # 00008 # The PyMite VM is distributed in the hope that it will be useful, 00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00011 # A copy of the GNU GENERAL PUBLIC LICENSE Version 2 00012 # is seen in the file COPYING in this directory. 00013 */ 00014 00015 00016 #ifndef __THREAD_H__ 00017 #define __THREAD_H__ 00018 00019 00020 /** 00021 * \file 00022 * \brief VM Thread 00023 * 00024 * Encapsulating a frame pointer, a root code object and thread state. 00025 */ 00026 00027 00028 #include "interp.h" 00029 00030 00031 /** Frequency in Hz to switch threads */ 00032 #define THREAD_RESCHEDULE_FREQUENCY 10 00033 00034 00035 /** 00036 * Interpreter return values 00037 * 00038 * Used to control interpreter loop 00039 * and indicate return value. 00040 * Negative values indicate erroneous results. 00041 * Positive values indicate "continue interpreting", 00042 * but first do something special like reschedule threads 00043 * or (TBD) sweep the heap. 00044 */ 00045 typedef enum PmInterpCtrl_e 00046 { 00047 /* other erroneous exits go here with negative values */ 00048 INTERP_CTRL_ERR = -1, /**< Generic error causes exit */ 00049 INTERP_CTRL_EXIT = 0, /**< Normal execution exit */ 00050 INTERP_CTRL_CONT = 1, /**< Continue interpreting */ 00051 INTERP_CTRL_RESCHED = 2 /**< Reschedule threads */ 00052 /* all positive values indicate "continue interpreting" */ 00053 } PmInterpCtrl_t, *pPmInterpCtrl_t; 00054 00055 /** 00056 * Thread obj 00057 * 00058 */ 00059 typedef struct PmThread_s 00060 { 00061 /** object descriptor */ 00062 PmObjDesc_t od; 00063 00064 /** current frame pointer */ 00065 pPmFrame_t pframe; 00066 00067 /** 00068 * Interpreter loop control value 00069 * 00070 * A positive value means continue interpreting. 00071 * A zero value means normal interpreter exit. 00072 * A negative value signals an error exit. 00073 */ 00074 PmInterpCtrl_t interpctrl; 00075 } PmThread_t, 00076 *pPmThread_t; 00077 00078 00079 /** 00080 * Constructs a thread for a root frame. 00081 * 00082 * @param pframe Frame object as a basis for this thread. 00083 * @param r_pobj Return by reference; Ptr to the newly created thread object. 00084 * @return Return status 00085 */ 00086 PmReturn_t thread_new(pPmObj_t pframe, pPmObj_t *r_pobj); 00087 00088 #endif /* __THREAD_H__ */
Generated on Tue Jul 12 2022 17:07:01 by
