News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Writing to a logfile

Started by sinsi, October 31, 2012, 07:53:33 PM

Previous topic - Next topic

hutch--

Sinsi,

how much data do you need to pass to the log file each interval ? Is it 1 or 2 DWORD values or does it need to be a more complex form of data ?

sinsi

Not too much, just the basics

;right now
gputemp dd ?
fanrpm  dd ?
;later
cputemp dd cores dup (?)

I think the core temps might use privileged instructions, is rdmsr one?
I might put the time too, once I figure time functions out...
🍺🍺🍺

hutch--

I have sketched up a basic logger that registers a custom windows message and creates a memory mapped file. This will allow any sized data to be passed. What I need to know is what data format you want to pass, numbers, strings or any combination of both in a structure. I have made the memory mapped file 64k but it can be any size so passing large amounts of data is no big deal.

dedndave

RDMSR is a definitely a privileged instruction

Gunther

Hi Dave,

Quote from: dedndave on November 10, 2012, 11:04:06 PM
RDMSR is a definitely a privileged instruction

yes it is. There are Linux tools available to use that instruction: http://linux.koolsolutions.com/2009/09/19/howto-using-cpu-msr-tools-rdmsrwrmsr-in-debian-linux/ But take care.

Gunther
You have to know the facts before you can distort them.

dedndave

Agner Fog has a 32/64 driver set that can be used...

http://www.agner.org/optimize/#testp

you want testp.zip - inside that, you'll find DriverSrcWin.zip
it includes the drivers and a .H file that is pretty simple to convert to .INC

i also found this link
which, after reading it, leads me to believe it isn't a simple task to get the temp
(refering to the reply by uvts_cvs dated Jul 24, 2011)
but, it may be misinformation - lol

http://stackoverflow.com/questions/5327203/how-to-access-cpus-heat-sensors

hutch--

Sinsi,

This is a scruffy example of the suggestion I made to use a remote app to log the data from your test app.

It is 2 test pieces, one sends the data, the other is a remote application that receives the data using a memory mapped file and sending a custom message with the HWND_BROADCAST handle.

It only displays the sent data in 4 message boxes but the idea works and it would be easily fast enough to do what you want.

PBrennick

you can't think of this problem in human terms, a second for us is fast; for a computer it is dead slow.
I like Hutch's method of a 'push/pull' it is very efficient.

Hi everybody,

Paul

jj2007

Why use a cannon to kill a fly?

include \masm32\MasmBasic\MasmBasic.inc   ; download
  Init
  Kill "test.tmp"
  mov ebx, 100
  .Repeat
       Print "*"
       Open "A", #1, "test.tmp"   ; open file in Append mode
       mov eax, 1000
       cdq
       div ebx
       Print #1, Str$(eax), " "   ; write 1000/ebx, will crash for ebx=0
       Close
       dec ebx
  .Until Sign?
  Inkey "You will never see this, haha"
  Exit
end start

Last entries in test.tmp: 333 500 1000

@Paul: Welcome back, nice to see you!

PsYcHoCoDe

imho fastest/optimized scheme would be mapping file to memory, eventually using WRITE_COPY in order to be able to fix up a progress errors, when they occur (sort of backup of file) and after everything went fine, just write the image to disk ;) (i'm not an expert, just trying to help, don't flame me too much... :P)

hutch--

 :biggrin:

JJ,

nuking flies is good practice but in the case that sinsi described where he wanted to log data right up to the end where there was some risk of the source crashing, a remote app doing the logging was the basic idea so it stayed up even if the source app went down. A memory mapped file and a SendMessage using the HWND_BROADCAST handle is simple enough to code and it is genuinely fast which may help if a higher sampling rate is required.

jj2007

Quote from: hutch-- on November 17, 2012, 09:55:38 AM
... if a higher sampling rate is required.

Hutch, he wants to monitor CPU temperature. Once a minute would be generous  :biggrin:
On my slow old Celeron notebook, the open, write & close sequence takes less than 0.4 milliseconds...

hutch--

Depends on the task, I would happily write it directly to disk in most instances but the task defined a risk of the source crashing, this is why its done as a remote logger, not a direct process. I think he was after logging at about 1 second intervals but the memory mapped file and SendMessage will handle much faster again but the big win is it will handle much larger amounts of data each interval than you will with file IO.

dedndave

the temp probably doesn't change all that fast
i would think once every 5 or 10 seconds would be ample   :P
he seems to only want to write a few bytes each time - keep it simple

sinsi

The GPU temps can go from 52 to 62 in 2-3 seconds, this is normal for the card (GTX 580).
What NVidia won't say is the upper limit, so 80C might be OK on one system but overheat on another.

It looks like, in this case, the GPU isn't the problem. I used the motherboard program to check CPU temps, and by
alt-tabbing could check, the CPU gets up to 90C as far as I can tell. Six cores working flat out gives off a lot of heat.
AMD CPUs are notorious for running hot then freezing, Intel seem to slow down until the system shuts off.
Having both fans (CPU and case) running high from start keeps it to 85C max, but is bloody noisy.

The method I finally used was open>setfilepointer>write>close every 500ms.
A couple of times, using tedd's way, chkdsk found free space marked as used and the logfile was 0KB.

Got some good ideas from this discussion, so thanks you blokes :t
🍺🍺🍺