2008/4/30 John M McIntosh johnmci@smalltalkconsulting.com:
On Apr 29, 2008, at 12:33 PM, Matthew Fulmer wrote:
The intent was to get polling out of the VM and make it more event driven. Maybe what that means here is that scheduling a timer interrupt is now not part of ioRelinquishProcessorForMicroseconds anymore. I'm not familiar with the old way the VM works; I've only seen the hydra way
-- Matthew Fulmer -- http://mtfulmer.wordpress.com/
Ah, ok, well I sent Igor a copy of my current work on the hydra semaphore mutex calls. If you have a InterlockedCompareExchange, and a ioWakeUp() routine that you can share that would be helpful.
To support non-atomic event queues (wrapped by mutex), some things need to be changed:
typedef struct vmEventQueue { struct vmEvent * volatile tail; struct vmEvent head; VM_EVENT_QUEUE_PLATFORM_SPECIFIC } vmEventQueue;
then you can #define VM_EVENT_QUEUE_OS_SPECIFIC pthread_mutex queue_lock; and also, there are need in additional function to finalize queue: ioDestroyEventQueue(..)
Currently, i placed vmEventQueue in sqMemoryAccess.h header file, not sure if platform specific stuff loaded before that header.
About ioWakeUp and event handling: - if its possible to handle user input from OS in separate thread, then things can be greatly simplified.
in ioRelinquishProcessorForMicroseconds you simply put wait for wakeupEvent (pthread's conditional variable), and in OS thread, which handling events - just translate event, put it into VM event queue and then call ioWakeUp which should signal wakeupEvent.
In another i/o frameworks , like socket plugin or async file plugin, things can be done very similar: in own thread, whenever it sees i/o activity, it just posts VM event and calls ioWakeUp() at the end. This will eliminate the need to keep track of numerous file handles, as i saw in current implementation of ioRelinquishProcessorForMicroseconds() for unix VM port.
Also, if events are not of critical importance, you can just put them in queue, VM will handle them sooner or later. In contrast to old implementation, where you needed to call forceInterruptCheck(), in Hydra the Interpreter loop interrupts immediately only and only if there are event in its queue, so, in most cases you just need to post event and you are done.
--
John M. McIntosh johnmci@smalltalkconsulting.com Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ===========================================================================