This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Improving setitimer resolution


I am trying to improve the resolution of the Cygwin timers
(setitimer, alarm, ualarm) by using the multimedia timers,
which have 1 ms resolution.

It almost works fine. For example on ME notebook, 600 MHz clock,
and setitimer with a 1 ms period, the sigalarm handler can
print gettimeofday every ms.
1058406898 s, 104000 us
1058406898 s, 105000 us
1058406898 s, 106000 us
1058406898 s, 107000 us

Compare with 1.5:
1058408626 s, 135000 us
1058408626 s, 189000 us
1058408626 s, 245000 us

However running under strace leads to freezes and power cycling.
The trace first starts normal but eventually goes into an 
unexpected pattern, where only the sig task and the Windows
multimedia callback task [which calls raise()] run, but not 
the Cygwin sigalarm handler (although the caller is supposed
to wait for the handler). Here is one period, starting and 
ending with the Windows callback, but without a cygwin callback.

  217  217682 [unknown (0xFFFCA1FF)] a 103117 timer_callback: TimerID
5308428 timer_active 5308428
  198  217880 [unknown (0xFFFCA1FF)] a 103117 kill: kill (103117, 14)
  186  218066 [unknown (0xFFFCA1FF)] a 103117 sig_send: pid 103117, signal
-2, its_me 1
  223  218289 [unknown (0xFFFCA1FF)] a 103117 sig_send: Waiting for
thiscomplete 0x9C
   35  218324 [sig] a 103117 wait_sig: awake
  462  218786 [sig] a 103117 wait_sig: processing signal -2
  182  218968 [sig] a 103117 wait_sig: signal 14 blocked
  221  219189 [sig] a 103117 wait_sig: looping
   32  219221 [unknown (0xFFFCA1FF)] a 103117 sig_send: returning 0 from
sending signal -2
  445  219666 [unknown (0xFFFCA1FF)] a 103117 sig_send: pid 103117, signal
14, its_me 1
  223  219889 [unknown (0xFFFCA1FF)] a 103117 sig_send: Waiting for
thiscomplete 0x9C
   35  219924 [sig] a 103117 wait_sig: awake
  446  220370 [sig] a 103117 wait_sig: signal 14 blocked
  217  220587 [sig] a 103117 wait_sig: looping
   51  220638 [unknown (0xFFFCA1FF)] a 103117 sig_send: returning 0 from
sending signal 14
  430  221068 [unknown (0xFFFCA1FF)] a 103117 kill_worker: 0 = kill_worker
(103117, 14)
  197  221265 [unknown (0xFFFCA1FF)] a 103117 timer_callback: TimerID
5308428 timer_active 5308428

I don't know where the problem is. Any help would be appreciated, the signal
code isn't obvious... 
I am attaching the test program and the beginning of the trace. 

Incidentally how-signals-work says
"After determining that sigsave is available, setup_handler will take one
of two routes, depending on whether the main thread is executing in the
cygwin DLL or is currently in "user" code.  We'll discuss the cygwin DLL
case first."
Is the second case discussed?

Pierre
  

Attachment: try_sigloop.c
Description: Text document

Attachment: trace
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]