View Single Post
  #1539  
Old 05-05-2023, 01:52
Junior53's Avatar
Junior53 Junior53 is offline
Registered User
 
Join Date: May 2023
Location: Sri Lanka
Posts: 25
Thanks: 23
Thanked 32 Times in 10 Posts
Junior53 is on a distinguished road
Question Can someone explain what this is used for and what is filemapping?

Code:
function CreateFileMapping(
  File: Cardinal; Attributes: Cardinal; Protect: Cardinal;
  MaximumSizeHigh: Cardinal; MaximumSizeLow: Cardinal; Name: PAnsiChar): Cardinal;
  external '[email protected] stdcall';
  
function MapViewOfFile(
  FileMappingObject: THandle; DesiredAccess: Cardinal; FileOffsetHigh: Cardinal;
  FileOffsetLow: Cardinal; NumberOfBytesToMap: Cardinal): PChar;
  external '[email protected] stdcall';
What is FileMapping & benefits of FileMapping?

File mapping is a technique that allows you to map the contents of a file into the virtual memory space of a process. This allows you to access the contents of the file as if it were in memory, rather than on disk.
There are several benefits to using file mapping:

• Performance: File mapping can improve the performance of file I/O operations by reducing the number of disk accesses. When you map a file into memory, the operating system can use its virtual memory management mechanisms to cache the contents of the file in memory. This means that subsequent accesses to the file can be satisfied from memory, rather than requiring a disk access.

• Concurrency: File mapping allows multiple processes to access the same file concurrently. When multiple processes map the same file into their virtual memory space, they can all access the contents of the file simultaneously. This can be useful for inter-process communication and data sharing.

• Ease of use: File mapping allows you to access the contents of a file using memory-mapped I/O operations, rather than traditional file I/O operations. This can make it easier to work with files, as you can use pointer arithmetic and other memory-based operations to manipulate the contents of the file.
Overall, file mapping is a powerful technique that can improve the performance and ease-of-use of file I/O operations. It is widely used in many different types of applications and is supported by most modern operating systems.

Last edited by Junior53; 07-06-2023 at 17:37. Reason: I found the answer myself :)
Reply With Quote