Stack Threads and Exceptions - stackthread.d - qthread.d

Frank Benoit benoit__ at __tionex.de
Mon Apr 3 15:43:35 PDT 2006


mclysenk at mtu.edu schrieb:
> As soon as I am done with classes I will attempt to create a
> full library based on the concept, with support for linux.

That would be great.

What I do not understand is ...
Is this complete saving of context really necessary? There is no action
which is interrupted. If you have only cooperative thread switches, than
the switches always occurs in a yield function. Isn't it enough to set
the stackpointer to the other thread and return?

I think of an environment where there is one initial thread (called
master). It can create StackThreads as slaves. Switching is allway only
cooperative and is only between the master and his slaves. The master
thread is also the scheduler. The master has to have a loop where he
calls the slaves, until all slaves are complete.
Switching than should be lightning fast.

I need this for simulation threads. Each thread does one kind of job. If
the thread wants to proceed in time, he can increment his local time and
yield. The master allways calls the slave with the lowest local time.
The whole cluster is a normal pthread and can be interrupted preemptive
by other pthreads.
There are so many switches between these simulation threads, i think
StackThreads can really boost the performance.



More information about the Digitalmars-d mailing list