An NKS virtual machine (VM) is a containment boundary for hosting a single process. It loads, executes, and either completes on its own or is shut down by an external source.
Either way, there may be tasks such as resource cleanup that need to be performed by the hosted process before it completely shuts down. This sample code shows how to handle VM termination so that shut down will be clean. It demonstrates how to implement a VM exit handling function that will be called no matter which way the VM is shut down, how to signal threads to execute cleanup code, and how to ensure threads are not killed until they have executed cleanup code.
In the process of demonstrating VM exit handling techniques, this code also demonstrates how to synchronize access to global state using a mutex, force thread execution order based on global state, and create a new thread with a bound context. The following NKS APIs are used in this sample code:
NXMutexInit NXLock NXUnlock NXThreadYield NXStrError NXVmRegisterExitHandler NX_THREAD_CREATE nxCancelDisable nxCancelEnable
| xvme001.exe | 102.5 K | 2005-04-06 |
--ndkwp
© 2009 Novell, Inc. All Rights Reserved.