public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Houder <houder@xs4all.nl>
To: cygwin@cygwin.com
Subject: Re: MinTTY requires gdiplus.dll ? (2)
Date: Sat, 01 Dec 2018 08:57:00 -0000	[thread overview]
Message-ID: <fb45509f322f95b57ae075c05260383a@xs4all.nl> (raw)
In-Reply-To: <20181130131918.GI30649@calimero.vinschen.de>

On 2018-11-30 14:19, Corinna Vinschen wrote:
[snip]

> I'm trying to avoid remote debugging so I rather try to reproduce this
> @work.  However, if you're interested in debugging this, set a
> breakpoint to clk_monotonic_t::now() and observe how the call to the
> virtual init() method hangs or crashes.  If you find out why, I'd be
> most grateful.

Below I included parts of the diff between 1126 and 1129. You have been
refactoring the code related to "timing".

Above you state that the call to init() (clk_monotonic_t::init(), is my
understanding) from clk_monotonic_t::now() makes the cygwin1.dll end up
in "some mysterious loop" (my wording). At least on pre-W10 ...

Looking at the code (trying to understand it), it appears to me that it
is NOT "Windows version" dependent ...

My question: why do you claim in

     https://cygwin.com/ml/cygwin/2018-11/msg00261.html

that Windows 10 is NOT affected? Does W10 run a different "thread" in
the Cygwin codebase?

Regards,
Henri

======
https://cygwin.com/snapshots/x86/cygwin-diffs-20181126-20181129

FILE: winsup/cygwin/clock.h:

+class clk_t
+{
+ protected:
+  LONG inited;
+  LONGLONG ticks_per_sec;
+  virtual void init ();
+  virtual int now (clockid_t, struct timespec *) = 0
...

+class clk_monotonic_t : public clk_t
+{
+ protected:
+  virtual void init ();
+ private:
+  virtual int now (clockid_t, struct timespec *);
+};
...

FILE: winsup/cygwin/clock.cc:

+void
+clk_t::init ()
+{
+  spinlock spin (inited, 1);
+  if (!spin)
+    ticks_per_sec = system_tickcount_resolution ();
+}
+
...

+void
+clk_monotonic_t::init ()
+{
+  spinlock spin (inited, 1);
+  if (!spin)
+    ticks_per_sec = system_qpc_resolution ();
+}
...

+int
+clk_monotonic_t::now (clockid_t clockid, struct timespec *ts)
+{
+  if (wincap.has_precise_interrupt_time ())
+    {
+      /* Suspend time not taken into account, as on Linux */
+      ULONGLONG now;
+
+      QueryUnbiasedInterruptTimePrecise (&now);
+      ts->tv_sec = now / NS100PERSEC;
+      now %= NS100PERSEC;
+      ts->tv_nsec = now * (NSPERSEC/NS100PERSEC);
+    }
+  else
+    {
+      /* https://stackoverflow.com/questions/24330496.  Skip rounding 
since
+         its almost always wrong when working with timestamps */
+      UINT64 bias;
+      LARGE_INTEGER now;
+      struct timespec bts;
+
+      if (inited <= 0)
+       init ();                // Henri: invocation of 
clk_monotonic_t::init()
+      do
+       {
+         bias = SharedUserData.InterruptTimeBias;
+         QueryPerformanceCounter(&now);
+       }
+      while (bias != SharedUserData.InterruptTimeBias);
+      /* Convert perf counter to timespec */
+      ts->tv_sec = now.QuadPart / ticks_per_sec;
+      now.QuadPart %= ticks_per_sec;
+      ts->tv_nsec = (now.QuadPart * NSPERSEC) / ticks_per_sec;
+      /* Convert bias to timespec */
+      bts.tv_sec = bias / NS100PERSEC;
+      bias %= NS100PERSEC;
+      bts.tv_nsec = bias * (NSPERSEC/NS100PERSEC);
+      /* Subtract bias from perf */
+      ts_diff (bts, *ts);
+    }
+  return 0;
+}

=====

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

  parent reply	other threads:[~2018-12-01  8:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-29 18:42 Houder
2018-11-29 19:58 ` Corinna Vinschen
2018-11-29 22:11   ` Thomas Wolff
2018-11-29 22:40     ` Houder
2018-11-29 23:35     ` Houder
2018-11-30 12:17     ` Corinna Vinschen
2018-11-30 12:42   ` Houder
2018-11-30 13:19     ` Corinna Vinschen
2018-11-30 14:06       ` Houder
2018-12-01  8:57       ` Houder [this message]
2018-12-01  9:49         ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fb45509f322f95b57ae075c05260383a@xs4all.nl \
    --to=houder@xs4all.nl \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).