2 # This file is Copyright 2007, 2009, 2010 Dean Hall.
4 # This file is part of the PyMite VM.
5 # The PyMite VM is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU GENERAL PUBLIC LICENSE Version 2.
8 # The PyMite VM is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 # A copy of the GNU GENERAL PUBLIC LICENSE Version 2
12 # is seen in the file COPYING in this directory.
24 * Encapsulating a frame pointer, a root code object and thread state.
31 /** Frequency in Hz to switch threads */
32 #define THREAD_RESCHEDULE_FREQUENCY 10
36 * Interpreter return values
38 * Used to control interpreter loop
39 * and indicate return value.
40 * Negative values indicate erroneous results.
41 * Positive values indicate "continue interpreting",
42 * but first do something special like reschedule threads
43 * or (TBD) sweep the heap.
45 typedef enum PmInterpCtrl_e
47 /* other erroneous exits go here with negative values */
48 INTERP_CTRL_ERR
= -1, /**< Generic error causes exit */
49 INTERP_CTRL_EXIT
= 0, /**< Normal execution exit */
50 INTERP_CTRL_CONT
= 1, /**< Continue interpreting */
51 INTERP_CTRL_RESCHED
= 2 /**< Reschedule threads */
52 /* all positive values indicate "continue interpreting" */
53 } PmInterpCtrl_t
, *pPmInterpCtrl_t
;
59 typedef struct PmThread_s
61 /** object descriptor */
64 /** current frame pointer */
68 * Interpreter loop control value
70 * A positive value means continue interpreting.
71 * A zero value means normal interpreter exit.
72 * A negative value signals an error exit.
74 PmInterpCtrl_t interpctrl
;
80 * Constructs a thread for a root frame.
82 * @param pframe Frame object as a basis for this thread.
83 * @param r_pobj Return by reference; Ptr to the newly created thread object.
84 * @return Return status
86 PmReturn_t
thread_new(pPmObj_t pframe
, pPmObj_t
*r_pobj
);
88 #endif /* __THREAD_H__ */