flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution
"Best" in what way?
What are your goals? What are your requirements? It all depends upon what you are doing. |
|||
![]() |
|
a115433
send file over network
|
|||
![]() |
|
LocoDelAssembly
|
|||
![]() |
|
f0dder
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 ![]() |
|||
![]() |
|
revolution
a115433 wrote: send file over network |
|||
![]() |
|
a115433
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. |
|||
![]() |
|
revolution
a115433 wrote: fast, simple, better, and without pointless resource waste. |
|||
![]() |
|
LocoDelAssembly
TransmitFile seems to provide all that (although I'm not sure about the "pointless resource waste")
|
|||
![]() |
|
revolution
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?
|
|||
![]() |
|
a115433
forget about TransmitFile, what are the flaws of memory mapped io?
|
|||
![]() |
|
peter
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.
|
|||
![]() |
|
a115433
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? |
|||
![]() |
|
baldr
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. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.