[M3devel] question on use of Time.Now in thread test program
Daniel Alejandro Benavides D.
dabenavidesd at yahoo.es
Tue Mar 15 00:21:49 CET 2011
Hi all:
see at:
http://www.ic.unicamp.br/~stolfi/EXPORT/software/m3/Misc.html
CPUTime module.
Thanks in advance
--- El lun, 14/3/11, Jay K <jay.krell at cornell.edu> escribió:
De: Jay K <jay.krell at cornell.edu>
Asunto: Re: [M3devel] question on use of Time.Now in thread test program
Para: rcolebur at scires.com, "m3devel" <m3devel at elegosoft.com>
Fecha: lunes, 14 de marzo, 2011 18:07
Time.Now() is very cheap on Windows and should cause no concern.
It is just GetSystemTimeAsFileTime, which just reads some globals, followed by a simple unit and integer to double conversion.
I would avoid 64bit Windows for now, very unfortunate, but I don't trust GetThreadContext.
PROCEDURE Now(): T=
VAR
fileTime: WinBase.FILETIME;
BEGIN
WinBase.GetSystemTimeAsFileTime(fileTime);
RETURN TimeWin32.FromFileTime(fileTime);
END Now;
double
__cdecl
TimeWin32__FromFileTime(FILETIME ft)
{
LARGE_INTEGER li;
li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime;
return ((double)li.QuadPart) / 1.0e7;
}
Hm -- I don't like passing structs by value, too hard to be sure how it works -- I'd like to change this to be "READONLY" -- passed by pointer.
Maybe code the entire thing in Modula-3 -- or more likely, the entire thing in C.
Time.Now() might be more expensive on other platform, I don't know.
I also see some failures, some success, no pattern.
I think the success is just luck and the code is by its nature very non-deterministic.
- Jay
From: rcolebur at SCIRES.COM
To: m3devel at elegosoft.com
Date: Mon, 14 Mar 2011 18:45:44 -0400
Subject: [M3devel] question on use of Time.Now in thread test program
#yiv1082952660 .yiv1082952660ExternalClass p.yiv1082952660ecxMsoNormal, #yiv1082952660 .yiv1082952660ExternalClass li.yiv1082952660ecxMsoNormal, #yiv1082952660 .yiv1082952660ExternalClass div.yiv1082952660ecxMsoNormal
{margin-bottom:.0001pt;font-size:11.0pt;font-family:'sans-serif';}
#yiv1082952660 .yiv1082952660ExternalClass a:link, #yiv1082952660 .yiv1082952660ExternalClass span.yiv1082952660ecxMsoHyperlink
{color:blue;text-decoration:underline;}
#yiv1082952660 .yiv1082952660ExternalClass a:visited, #yiv1082952660 .yiv1082952660ExternalClass span.yiv1082952660ecxMsoHyperlinkFollowed
{color:purple;text-decoration:underline;}
#yiv1082952660 .yiv1082952660ExternalClass span.yiv1082952660ecxEmailStyle17
{font-family:'sans-serif';color:windowtext;}
#yiv1082952660 .yiv1082952660ExternalClass .yiv1082952660ecxMsoChpDefault
{}
_filtered #yiv1082952660 {}
#yiv1082952660 .yiv1082952660ExternalClass div.yiv1082952660ecxWordSection1
{}
I have a question/concern regarding Mika’s thread test program.
Each of the threads makes use of the Time.Now() call during each iteration of the thread’s main loop.
I haven’t fully investigated, but does anyone have concern that so many calls to the system clock from multiple competing threads might have some side effect on the running of multiple threads?
I’ve also done some limited experimentation with use of counters to see how many times each type of thread is able to go thru its loop between reporting intervals.
I continue to see various types of crashes on Windows 7 (64-bit), but sometimes tests are able to succeed. I haven’t found a repeatable pattern yet to the crashes, so I am still investigating, but just thought it worth asking the above question about use of Time.Now().
I will also try to experiment with Windows XP 32-bit and report back.
Regards,
Randy Coleburn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20110314/5b36d1fd/attachment-0002.html>
More information about the M3devel
mailing list