Hello,
I am the student who is working for the SqueakGtk plugin and I have a small problem. For the events handling there is an *active waiting system* like this :
mainLoopProcess := [ [ [self doMainIteration. self doSignalProcessing] forkAt: Processor userBackgroundPriority + 1 ] repeat ] forkAt: Processor userBackgroundPriority
It consumes a lot of cpu time. the problem is the method doMainIteration which call a C method to get an hypothetic event, I would like to replace this C method by an other method but this new method will block the interpreter until there is an event.
To solve this problem I'll create a C thread and say to the vm change the status of the current process call the blocking method and when there is an event wake up the process to say I've finished my work.
Is there a way to solve this problem ?
Cheers, Gwenael
Am 11.07.2008 um 13:26 schrieb Gwenael Casaccio:
Hello,
I am the student who is working for the SqueakGtk plugin and I have a small problem. For the events handling there is an *active waiting system* like this :
mainLoopProcess := [ [ [self doMainIteration. self doSignalProcessing] forkAt: Processor userBackgroundPriority
- 1 ] repeat ] forkAt: Processor userBackgroundPriority
It consumes a lot of cpu time. the problem is the method doMainIteration which call a C method to get an hypothetic event, I would like to replace this C method by an other method but this new method will block the interpreter until there is an event.
To solve this problem I'll create a C thread and say to the vm change the status of the current process call the blocking method and when there is an event wake up the process to say I've finished my work.
Is there a way to solve this problem ?
The canonical way to do this is have the Smalltalk process wait on a Semaphore, and signal that Semaphore from the VM if there is anything to do. See senders of "Smalltalk registerExternalObject: someSemaphore" for examples.
- Bert -
On 11 Jul 2008, at 13:30, Bert Freudenberg wrote:
Am 11.07.2008 um 13:26 schrieb Gwenael Casaccio:
Hello,
I am the student who is working for the SqueakGtk plugin and I have a small problem. For the events handling there is an *active waiting system* like this :
mainLoopProcess := [ [ [self doMainIteration. self doSignalProcessing] forkAt: Processor userBackgroundPriority + 1 ] repeat ] forkAt: Processor userBackgroundPriority
It consumes a lot of cpu time. the problem is the method doMainIteration which call a C method to get an hypothetic event, I would like to replace this C method by an other method but this new method will block the interpreter until there is an event.
To solve this problem I'll create a C thread and say to the vm change the status of the current process call the blocking method and when there is an event wake up the process to say I've finished my work.
Is there a way to solve this problem ?
The canonical way to do this is have the Smalltalk process wait on a Semaphore, and signal that Semaphore from the VM if there is anything to do. See senders of "Smalltalk registerExternalObject: someSemaphore" for examples.
- Bert -
Thanks for you answer !
Gwenael
On Fri, Jul 11, 2008 at 01:30:43PM +0200, Bert Freudenberg wrote:
To solve this problem I'll create a C thread and say to the vm change the status of the current process call the blocking method and when there is an event wake up the process to say I've finished my work.
Is there a way to solve this problem ?
The canonical way to do this is have the Smalltalk process wait on a Semaphore, and signal that Semaphore from the VM if there is anything to do. See senders of "Smalltalk registerExternalObject: someSemaphore" for examples.
The SocketPlugin uses this technique, and you can find additional examples in AioPlugin (notify a Smalltalk process on IO activity) and OSProcessPlugin (notify a Smalltalk process on termination of an external process). These are on SqueakMap/SqueakSource.
Dave
Hi!
Note that already the original (before Luca Bruno's work on it) SqueakGtk included code for this mechanism. It even queued the events on the plugin side.
regards, Göran
David T. Lewis wrote:
On Fri, Jul 11, 2008 at 01:30:43PM +0200, Bert Freudenberg wrote:
To solve this problem I'll create a C thread and say to the vm change the status of the current process call the blocking method and when there is an event wake up the process to say I've finished my work.
Is there a way to solve this problem ?
The canonical way to do this is have the Smalltalk process wait on a Semaphore, and signal that Semaphore from the VM if there is anything to do. See senders of "Smalltalk registerExternalObject: someSemaphore" for examples.
The SocketPlugin uses this technique, and you can find additional examples in AioPlugin (notify a Smalltalk process on IO activity) and OSProcessPlugin (notify a Smalltalk process on termination of an external process). These are on SqueakMap/SqueakSource.
Dave
vm-dev@lists.squeakfoundation.org