Patent ID: 7895597

Claim:
A method comprising: prior to executing a native code thread in a virtual machine environment comprised of at least one virtual machine that is running in a non-interpreted green thread mode, storing a pointer pointing to a current top of a stack; initiating an interrupt generator to generate an interrupt; beginning execution of the native code thread, the stack being used during execution of the native code thread by the virtual machine; and upon an occurrence of the interrupt generated by the interrupt generator, determining if the native code thread is still being executed by the virtual machine and, if it is, verifying that the executing native code thread can be safely interrupted and, only if it is verified that execution of the native code thread can be safely interrupted; recording a state of the native code thread comprising saving a top portion of the stack in a memory, the top portion of the stack comprising a portion above the point indicated by the stored pointer and being the portion of the stack used during the execution of the native code thread by the virtual machine; interrupting execution of the native code thread by the virtual machine; and when returning to continue to execute the interrupted native code thread, retrieving the stored state of the native code thread by reading the saved top portion of the stack from the memory and placing it back on the top of the stack.