Server Smalltalk Guide : Method invocation : Logical process invocation
Logical process invocation
Tip icon
To better understand this section, examine the sample SstPingPongLP*.
Logical processes are an extension of the standard Smalltalk process whose stack contents are distributed over multiple object spaces. Using a logical process, a message sent by Process A and handled by Process B will appear to be executed on the same logical stack. This effect is achieved by ensuring that whenever a message is sent, the sending Smalltalk process is associated with a logical process (LP) and attaching the LP to the outgoing message.
When a message is loaded into a remote object space, the LP tag acts as a remote reference and is looked up in the receiving space's import table. If no corresponding local logical process exists, one is created and installed in the import table. On creation of a Logical Process, a normal Smalltalk process is also created and attached to the LP. It is this Smalltalk process which is used to execute all messages for that LP.
To use logical processes, you must be using by-reference marshaling (see By-reference marshaling) and specify that an SstLPDispatcher (or equivalent) be used. In addition, their handlers must be configured to use reply futures (the replyFutureClass configuration option) which are interruptable (for example, SstInterruptableReplyFuture).
Logical processes are discussed extensively in Logical processes; refer to that section for an expanded overview of their characteristics.
Logical processes are particularly useful for debugging as they enable a distributed view of execution whereby debugging a program in one object space supports stepping into or over stack frames as they execute in other object spaces.
The same Smalltalk process will not necessarily be used to handle two non-causally related sends to the same object space. That is, if A sends M1 to B, B answers and then A sends M2 to B, the Smalltalk process used to handle M2 will not necessarily be the same as that used to handle M1.
Much of Smalltalk's traditional behavior is possible with LP Invocation. In addition to maintaining the distributed stack, logical processes maintain distributed notions of error handlers and UI handlers.
Tip icon
The use of asynchronous messages breaks any existing logical process chain.
Under LP dispatching rules, if an early return is requested, any remaining execution must be done in a different local process since the logical process has returned to the requestor. This process management is handled automatically by the LP system but you should be careful to ensure that all remaining code is in the continuation supplied to the early return operation.
Last modified date: 05/12/2020