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.
src/vm/thread.c@0:14e5e829dffe, 2010-07-21 (annotated)
- Committer:
- dadaista
- Date:
- Wed Jul 21 12:50:41 2010 +0000
- Revision:
- 0:14e5e829dffe
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| dadaista | 0:14e5e829dffe | 1 | /* |
| dadaista | 0:14e5e829dffe | 2 | # This file is Copyright 2007, 2009 Dean Hall. |
| dadaista | 0:14e5e829dffe | 3 | # |
| dadaista | 0:14e5e829dffe | 4 | # This file is part of the PyMite VM. |
| dadaista | 0:14e5e829dffe | 5 | # The PyMite VM is free software: you can redistribute it and/or modify |
| dadaista | 0:14e5e829dffe | 6 | # it under the terms of the GNU GENERAL PUBLIC LICENSE Version 2. |
| dadaista | 0:14e5e829dffe | 7 | # |
| dadaista | 0:14e5e829dffe | 8 | # The PyMite VM is distributed in the hope that it will be useful, |
| dadaista | 0:14e5e829dffe | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| dadaista | 0:14e5e829dffe | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| dadaista | 0:14e5e829dffe | 11 | # A copy of the GNU GENERAL PUBLIC LICENSE Version 2 |
| dadaista | 0:14e5e829dffe | 12 | # is seen in the file COPYING in this directory. |
| dadaista | 0:14e5e829dffe | 13 | */ |
| dadaista | 0:14e5e829dffe | 14 | |
| dadaista | 0:14e5e829dffe | 15 | |
| dadaista | 0:14e5e829dffe | 16 | #undef __FILE_ID__ |
| dadaista | 0:14e5e829dffe | 17 | #define __FILE_ID__ 0x16 |
| dadaista | 0:14e5e829dffe | 18 | |
| dadaista | 0:14e5e829dffe | 19 | |
| dadaista | 0:14e5e829dffe | 20 | /** |
| dadaista | 0:14e5e829dffe | 21 | * \file |
| dadaista | 0:14e5e829dffe | 22 | * \brief VM Thread |
| dadaista | 0:14e5e829dffe | 23 | * |
| dadaista | 0:14e5e829dffe | 24 | * Encapsulating a frame pointer, a root code object and thread state. |
| dadaista | 0:14e5e829dffe | 25 | */ |
| dadaista | 0:14e5e829dffe | 26 | |
| dadaista | 0:14e5e829dffe | 27 | |
| dadaista | 0:14e5e829dffe | 28 | #include "pm.h" |
| dadaista | 0:14e5e829dffe | 29 | |
| dadaista | 0:14e5e829dffe | 30 | |
| dadaista | 0:14e5e829dffe | 31 | PmReturn_t |
| dadaista | 0:14e5e829dffe | 32 | thread_new(pPmObj_t pframe, pPmObj_t *r_pobj) |
| dadaista | 0:14e5e829dffe | 33 | { |
| dadaista | 0:14e5e829dffe | 34 | PmReturn_t retval = PM_RET_OK; |
| dadaista | 0:14e5e829dffe | 35 | pPmThread_t pthread = C_NULL; |
| dadaista | 0:14e5e829dffe | 36 | |
| dadaista | 0:14e5e829dffe | 37 | C_ASSERT(pframe != C_NULL); |
| dadaista | 0:14e5e829dffe | 38 | |
| dadaista | 0:14e5e829dffe | 39 | /* If it's not a frame, raise TypeError */ |
| dadaista | 0:14e5e829dffe | 40 | if (OBJ_GET_TYPE(pframe) != OBJ_TYPE_FRM) |
| dadaista | 0:14e5e829dffe | 41 | { |
| dadaista | 0:14e5e829dffe | 42 | PM_RAISE(retval, PM_RET_EX_TYPE); |
| dadaista | 0:14e5e829dffe | 43 | return retval; |
| dadaista | 0:14e5e829dffe | 44 | } |
| dadaista | 0:14e5e829dffe | 45 | |
| dadaista | 0:14e5e829dffe | 46 | /* Allocate a thread */ |
| dadaista | 0:14e5e829dffe | 47 | retval = heap_getChunk(sizeof(PmThread_t), (uint8_t **)r_pobj); |
| dadaista | 0:14e5e829dffe | 48 | PM_RETURN_IF_ERROR(retval); |
| dadaista | 0:14e5e829dffe | 49 | |
| dadaista | 0:14e5e829dffe | 50 | /* Set type, frame and initialize status */ |
| dadaista | 0:14e5e829dffe | 51 | pthread = (pPmThread_t)*r_pobj; |
| dadaista | 0:14e5e829dffe | 52 | OBJ_SET_TYPE(pthread, OBJ_TYPE_THR); |
| dadaista | 0:14e5e829dffe | 53 | pthread->pframe = (pPmFrame_t)pframe; |
| dadaista | 0:14e5e829dffe | 54 | pthread->interpctrl = INTERP_CTRL_CONT; |
| dadaista | 0:14e5e829dffe | 55 | |
| dadaista | 0:14e5e829dffe | 56 | return retval; |
| dadaista | 0:14e5e829dffe | 57 | } |