Hey. I'm sure you've heard this before, but here's another vote:

Please provide get/set/make/swapcontext.
  (and/or kernel threads.)


They are Posix-standard, but, admittedly, deprecated.
And, admittedly, most applications can use pthreads instead.


Longer story:


Modula-3.
Provides threads in its runtime. Kind of like Java.
  (though we produce native, optionally safe, etc.)
We have 5 or so (!) options for providing them.


Win32 threads
pthreads


That covers just about all platforms.
Now, for some reason, and I still need to debug/understand this, OpenBSD
pthreads
don't work for us. We do need to be able to suspend/resume threads
and get their context while suspended. We have two ways of doing
this for pthreads platforms:
  send a signal and wait in the signal handler
    some use of semaphore here
  I think this semaphore thing runs afoul of typical usermode threading
  libraries, such as OpenBSD's.
  And apparently others e.g. FreeBSD and Darwin/MacOSX.
  On FreeBSD and Darwin we have custom code for suspend/resume.
  I think in some places it is based on the boehm gc.

  (In future we might do something like "cooperative suspend".
  Which should be extremely portable.)


Now, for systems without viable pthreads, we have another option.
We can use get/set/make/swapcontext. This is fairly simple, portable, and
  works fairly well. Albeit won't take advantage of multiprocessor systems.
 

But yet, some systems e.g.OpenBSD, don't have get/set/make/swapcontext.
Not to fear, we have another approach, using sigaltstack.
I thought I had this working on OpenBSD/x86, but I see hangs now.
I should look into it further.


So, the last option, desparate measure, requires per machine porting,
is hacking on the jmpbuf.
I have this working on x86, mips64 (loongson), powerpc, and maybe sparc64.
But I'd rather not resort to this.
(see
http://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/unix/C
ommon/context/setjmp)


Thanks,
 - Jay

Reply via email to