[Mono-dev] updated Timer patch (bug #66734) + discussion

Rafael Ferreira lists at ophion.org
Sat Nov 4 17:41:49 EST 2006

Gonzalo and others, 

here's an updated patch that fix the "deadlock" issue you found on my
original patch for bug 66734
(http://bugzilla.ximian.com/show_bug.cgi?id=65734). I found an issue
with an exception being thrown and the scheduler thread never releasing
the lock it had on the job q. A few other changes are noted below:

Changes from last patch:

* Fixed deadlock due to scheduler thread never releasing the jobs lock
* Updated TimerTests.cs to use attributes and Assert. instead of
* Created 7 new test cases 
* Fixed race condition between disposing and triggering a timer

Important things to note:

* Some tests cases still fail sporadically. On my system, that is most
likely due to inconsistent thread creation times (on my system is varies
anywhere from 1 msec to 30 msec) so test cases that expect the timer to
be triggered within an specific msec timeframe fail (such as

* TestDisposeOnCallback consistently fails and is still marked as
"NotWorking" (I was able to fix a bunch of the other NotWorking tests
cases). I'm not the one who wrote this test case originally but I tested
it on the MS runtime and the behavior is identical. I don't understand
it's purpose so I didn't want to touch it.  

* the scheduler dispatches timers by creating a new thread per dispatch
by default  (the CLR's threadpool can be used by exporting an env
variable). This works well for most cases but under significant amount
of timers (or with long running timers) the thread creation time becomes
more of an issue. I've talked with some people about creating a  thread
pool (or a threaded dispatching queue) and that would be fairly simple
to implement except for 2 things: Where would that "threadpool" exist...
something like an internal Timer.Threadpool, in Mono.Util or else? 
and how would the thread pool size be configured (env variables for
MIN/MAX or a percentage, lets say thread count = #Timers % 10

Let me know what you guys think, 

- raf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: timer-patch.20061104
Type: text/x-patch
Size: 21843 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061104/2f1004c0/attachment.bin 

More information about the Mono-devel-list mailing list