[M3devel] real timer vs. virtual timer in user threads?

Jay K jay.krell at cornell.edu
Mon Dec 14 17:31:29 CET 2009


Ok, so I tried sched_yield in my C testbed (m3core/src/unix/Common/context/sigaltstack).
It still seemed to hang.
(I realize you might not have meant that.)


So what happens if none of our user threads have any work? Is that possible?
Sure, I can make it so.
  Just create a bunch of threads that call the Modula-3 equivalent of sleep(big number).
Will they actually wake up after that time?
And we won't spin the CPU in the meantime?
I guess I should test it out..


I can see that "virtual" does seem maybe better than "real", if the virtual one is guaranteed to progress.
But I wonder also..you have OpenBSD/x86 or sparc64?
cd to that test bed, make, ./tcontext.
It always seemed kind of jerky.
I bet it'll seem "faster" with "real" timer.

 - Jay


From: hosking at cs.purdue.edu
Date: Mon, 14 Dec 2009 10:39:31 -0500
To: jkrell at elego.de
CC: m3commit at elegosoft.com
Subject: Re: [M3commit] CVS Update: cm3



Main thread should call Yield if you want that behavior, not sleep.


On 14 Dec 2009, at 14:57, Jay Krell wrote:CVSROOT:	/usr/cvs
Changes by:	jkrell at birch.	09/12/14 14:57:30

Added files:
	cm3/m3-libs/m3core/src/unix/Common/context/sigaltstack/: 
	                                                         Makefile 
	                                                         config.c 
	                                                         context.c 
	                                                         context.h 
	                                                         m3makefile 
	                                                         tcontext.c 

Log message:
	working version of http://www.engelschall.com/pw/usenix/2000/pmt-html/
	- This should be moved to m3core/src/thread/POSIX
	- Notice how I switched from virtual timer to real timer,
	in the test case that mimics m3core/src/thread/POSIX.
	"This seems to work much better."
	In particular, if the main thread does while (1) sleep(0)
	to let things run, nothing runs. The virtual time doesn't
	run down at all. If I make it a busy wait "while (1) ;" then
	it does work.
	
	Note that Apple seems very down on supplying get/make/set/swapcontext (read the mailing lists).
	This solution might be preferred? Though it is slower to create a thread here, due to
	extra gymnastics to establish the initial context.
	
	Also still some experiments to try.
	_setjmp vs. setjmp vs. sigsetjmp.
	Best is probably sigsetjmp(1).
	using the same signal in both parts

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20091214/9c948226/attachment-0001.html>


More information about the M3devel mailing list