[Patch]: Timer functions

Christopher Faylor cgf-no-personal-reply-please@cygwin.com
Mon Mar 7 03:59:00 GMT 2005

On Thu, Mar 03, 2005 at 11:45:45PM -0500, Pierre A. Humblet wrote:
>The attached patch implements the alarm, ualarm, setitimer and
>getitimer with the timer_xxx calls created by Chris last year.
>It has two objectives, both motivated by exim.
>- The current implementation of alarm() opens a hidden window.
>Thus, on Win9X, services calling alarm do not survive user logouts.
>- When running exim as a service under a privileged (non system)
>account on XP (trying out what's necessary on Win2003), I have hit
>api_fatal ("couldn't create window, %E") with error 5.
>The implementation of getitimer has necessitated the development
>of timer_gettime (not yet exported) and some changes to the logic
>of the timer_thread. I have also fixed a FIXME about race condition
>and two bugs: 
>- the initial code was not reusing the cygthreads (see attachment).
>The fix involves using "auto_release" in the timer thread instead of 
>"detach" in the calling function.
>- the mu_to was not reinitialized on forks (non-inheritable event).

I've fixed the above two problems in the current code and am going
through your patch trying to separate what looks like bug fixes from
what looks like enhanced functionality.

I am puzzled by a couple of things.

Why did you decide to forego using th->detach in favor of (apparently)

      while (running)
	low_priority_sleep (0);


I never liked the idea that a muto had to be allocated for the timer
functions regardless of whether they were going to be used.  You have
extended this so that now an event will be allocated and a more
complicated constructor will be called to fill out ttstart.  Is that
really necessary?

FWIW, I checked in a change to muto initialization which protects the
initialization with a CRITICAL_SECTION since I thought that I might be
able to gain back the extra handle by protecting the initialization with
a critical section but it looks like a critical section is more
expensive than I thought it was, so I'll probably revert that change.


More information about the Cygwin-patches mailing list