Programmer Reference : VAST Virtual Machine API : Asynchronous messages (interrupts)
Asynchronous messages (interrupts)
Interrupt handlers cannot send messages (using EsSendMessage) to the VA Smalltalk interpreter at arbitrary times. Interrupt-time messages must be queued for later processing when the virtual machine has regained control of the system. At certain checkpoints, the virtual machine polls the asynchronous message queue and sends any pending messages.
Because an interrupt handler could become active at any time (for example, when the virtual machine is garbage collecting), normal objects cannot be used in asynchronous messages. To support this, VA Smalltalk allows objects to become fixed, meaning that they do not move during a garbage collection.
When posting an asynchronous message, the receiver, selector, and any arguments must all be fixed objects. In Smalltalk, send makeFixed to all objects that will be used from interrupt handlers. After all of the objects are fixed, install the interrupt handler (for example, with a user primitive that takes the fixed receiver, selector, and arguments as parameters).
void EsPostNMI(EsVMContext vmContext)
Causes nmi to be sent to the active process at the next checkpoint. The message is sent even if the process has asynchronous messages disabled.
BOOLEAN EsPostAsyncMessage(EsVMContext vmContext, EsObject receiver, EsObject selector, U_32 argumentCount, ...)
Queues a message for processing by the active process at the next checkpoint. The message is not sent if the process has asynchronous messages disabled. All of the objects passed here must be fixed.
Error cases: If the message could not be queued for any reason, returns FALSE. TRUE indicates successful queuing.
When running an interrupt handler, EsPrimVMContext is not defined. During the interrupt handler installation user primitive, you must perform the following steps:
ESGlobalInfo * gInfo; /* These are globals */
EsObject receiver;
EsObject selector;
...
EsUserPrimitive(installInterruptHandler)
{
...save receiver/selector/args...
gInfo = EsPrimVMContext->globalInfo;
...install handler...
}
In the interrupt handler, pass gInfo->currentVMContext as the vmContext parameter in EsPostAsyncMessage and EsPostNMI.
Do not save EsPrimVMContext in a global and use it in the handler. The saved vmContext might not remain valid for the duration of the interrupt handler. The globalInfo is always valid.
Last modified date: 01/29/2015