[squeak-dev] process name in InterpreterSimulator
David T. Lewis
lewis at mail.msen.com
Sat Feb 6 21:22:50 UTC 2010
On Tue, Feb 02, 2010 at 09:40:46AM -0800, Ang BeePeng wrote:
>
> Hi all.
>
> I want to learn about processes, so I have InterpreterSimulator run, and try
> to print name of current running process. A process is an instance of
> SmallInteger ???not Process), is it because simulator process as VM point of
> view?
>
> How can I print a process name?
>
> http://askoh.net/mmu/beepeng/Smalltalk/Squeak/video/20100202-InterpreterSimulator/20100202-InterpreterSimulator.html
You are looking at an object pointer (OOP) referring to the process.
The integer value is a reference to a position in the object memory.
This object reference points to the object header of your Process
object (i.e. a location in the object memory), and one of the fields
in that object would be another OOP pointing to the header for the
process name (a string object).
I do not know an easy way to print the process name to the transcript
from within the simulated interpreter, but in principle you can start
with the object pointer value, use #longAt: to find the object header,
find the #name instance var in the object, do another #longAt: to get
the string object, and look at the values in the string object to figure
out the process name.
I'm sure there must be some simpler way, but I can't think of it
right now.
Dave
More information about the Squeak-dev
mailing list
|