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.
Diff: src/vm/thread.c
- Revision:
- 0:14e5e829dffe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/vm/thread.c Wed Jul 21 12:50:41 2010 +0000 @@ -0,0 +1,57 @@ +/* +# This file is Copyright 2007, 2009 Dean Hall. +# +# This file is part of the PyMite VM. +# The PyMite VM is free software: you can redistribute it and/or modify +# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 2. +# +# The PyMite VM is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# A copy of the GNU GENERAL PUBLIC LICENSE Version 2 +# is seen in the file COPYING in this directory. +*/ + + +#undef __FILE_ID__ +#define __FILE_ID__ 0x16 + + +/** + * \file + * \brief VM Thread + * + * Encapsulating a frame pointer, a root code object and thread state. + */ + + +#include "pm.h" + + +PmReturn_t +thread_new(pPmObj_t pframe, pPmObj_t *r_pobj) +{ + PmReturn_t retval = PM_RET_OK; + pPmThread_t pthread = C_NULL; + + C_ASSERT(pframe != C_NULL); + + /* If it's not a frame, raise TypeError */ + if (OBJ_GET_TYPE(pframe) != OBJ_TYPE_FRM) + { + PM_RAISE(retval, PM_RET_EX_TYPE); + return retval; + } + + /* Allocate a thread */ + retval = heap_getChunk(sizeof(PmThread_t), (uint8_t **)r_pobj); + PM_RETURN_IF_ERROR(retval); + + /* Set type, frame and initialize status */ + pthread = (pPmThread_t)*r_pobj; + OBJ_SET_TYPE(pthread, OBJ_TYPE_THR); + pthread->pframe = (pPmFrame_t)pframe; + pthread->interpctrl = INTERP_CTRL_CONT; + + return retval; +}