flat assembler
Message board for the users of flat assembler.
Index
> Windows > MapViewOfFile vs ReadFile |
Author |
|
revolution 08 Apr 2010, 12:07
"Best" in what way?
What are your goals? What are your requirements? It all depends upon what you are doing. |
|||
08 Apr 2010, 12:07 |
|
a115433 08 Apr 2010, 13:35
send file over network
|
|||
08 Apr 2010, 13:35 |
|
LocoDelAssembly 08 Apr 2010, 15:13
|
|||
08 Apr 2010, 15:13 |
|
f0dder 08 Apr 2010, 15:23
When dealing with files, memory is used. When mapping a hardware device into memory space things are different, but this isn't really something you do with CreateFileMapping+friends.
There's - possibly - slightly more overhead when dealing with memory-mapped files than normal Read/WriteFile calls, since you'll get a pagefault (including ring3->ring0->ring3) for every 4kb accessed. Probably not something you'll be able to seriously benchmark unless you get hold of a really old CPU, though |
|||
08 Apr 2010, 15:23 |
|
revolution 08 Apr 2010, 15:38
a115433 wrote: send file over network |
|||
08 Apr 2010, 15:38 |
|
a115433 08 Apr 2010, 16:13
Quote: since you'll get a pagefault please more info about it. in paging table memory mapped device has propably supervisor access bit set to 0, meaning that ring3 can access this memory. Its OS thing to allow or disallow ring3 access to memory, why would it restrict it to cpl < 3 when i havepermission to create mapping handle? Where do i have page fault? I doubt that OS will swap out memory wich is used for memory mapped device, it must keep track of it. Im not sure how it works, its my theory about it. Quote: "Best" in what way? fast, simple, better, and without pointless resource waste. |
|||
08 Apr 2010, 16:13 |
|
revolution 08 Apr 2010, 16:16
a115433 wrote: fast, simple, better, and without pointless resource waste. |
|||
08 Apr 2010, 16:16 |
|
LocoDelAssembly 08 Apr 2010, 16:27
TransmitFile seems to provide all that (although I'm not sure about the "pointless resource waste")
|
|||
08 Apr 2010, 16:27 |
|
revolution 08 Apr 2010, 16:44
Is TransmitFile actually "simple"? I imagine the OS has a lot of work to do internally. The OP has not stated what is meant by "best" or "better" so how can we know what is wanted?
|
|||
08 Apr 2010, 16:44 |
|
a115433 08 Apr 2010, 17:07
forget about TransmitFile, what are the flaws of memory mapped io?
|
|||
08 Apr 2010, 17:07 |
|
peter 26 Apr 2010, 02:43
Four years ago, I tested memory-mapped files (MMF) vs. ReadFile for large files on HDD under Win XP. The results: for uncached data (first-time read), the speed was similar, but if you read the same file again, MMF will be ≈2 times faster, because it does not have to copy the memory, just remap the memory pages from cache. MMF is harder to use: there are more functions to call, and you cannot grow a file once it's created.
|
|||
26 Apr 2010, 02:43 |
|
a115433 26 Apr 2010, 07:06
ok how does mmf work?
does it instruct OS to map portion of HDD space to address space? or is it something else, like creating page with no access, upon access calling page fault handler, redirecting to normal page, comparing 8 bytes, and using WriteFile/ReadFile to actually write data there? |
|||
26 Apr 2010, 07:06 |
|
baldr 26 Apr 2010, 07:47
a115433,
CPU usually can't directly address HDD space (PIO/DMA vs. memory-mapped I/O). x86 OS usually uses demand-paging to achieve mapping effect. WriteFile/ReadFile use cache manager which, in turn, uses memory manager to map sections of file into system virtual address space. |
|||
26 Apr 2010, 07:47 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.