native threads

Matej Kosik kosik at fiit.stuba.sk
Thu Apr 14 15:30:13 UTC 2005


Ramiro Diaz Trepat wrote:
> This might have been talked about before, but I wanted to ask.
> I started reading the list again, and a few days ago someone asked
> about why filling a shared queue on two separete processes filled it
> sequentially.  Someone else mentioned the issue of the "green threads"
> and answered with a propoer code snippet, showing that a Processor
> yield was needed to do the trick.
> I believe that no serious server software will ever be possible
> without preemtive multitasking, probably no client sofware either. 
> Hence this issue of the green threads really shocked me, and it
> surprised me that I never heard of plans for implementing such a high
> priority feature (if the objective is to make Squeak something else
> than a toy, of course).
> Green threads are such an anachronic technology, they remind me of
> Windows 3.11 :)
> Java was born with green threads, but it must be about 10 years since
> it has implemented native threads.
> Well, the question is of course, if the implementation of native
> threads is in the plans of the virtual machine wizards?
> Or did I get it all wrong and green threads are fine?
> Cheers !
> 
> 
> r.
> 
> 

As far as I know, Smalltalk processes are preemptive.

  m := Morph new openInWorld.
  [[true] whileTrue: [m color: m color darker]] forkAt: 23.
  [[true] whileTrue: [m color: m color lighter]] forkAt: 23.
  m color

when you then reevaluate the last expression you will see that both threads are running in parallel without any need for explicit yielding. Explicit yielding is (as it was point out before) there.

If the processes weren't preemptive, there would be no reason for things like Semaphore, SharedQueue, Monitor and similar stuff.
-- 
Matej Kosik, icq://300133844, http://altair.dcs.elf.stuba.sk/wiki/Kosik/Main



More information about the Squeak-dev mailing list