Skip to content
Cristian Gallardo edited this page Mar 18, 2020 · 4 revisions

Shared memory access library creation initiative

When having complex projects in which share information is required, several tools such as interconnection technologies, e. g., Interprocess Communication – IPC, can be used. This project offers an alternative to use Shared Memories in order to have access to a system memory space with reading and writing features available to processes, threads, and programs.

The project offers a shared memory manager that handles memory spaces and the type of data to be shared, allowing some library functions to access these memory spaces in order to write and read information with low latency.

This project started with the insight of having an exchange of information as quickly as possible and with the greatest simplicity. To achieve an exchange of data with low latency, this proposal does not offer a queue or storage of data to be consumed, but it allows that programmed functions update a memory space replacing the previous data, thus making it available to other customers only the current information. Simplicity is achieved by having a library with simple functions to access the memories and work with them, assuring that the data exchange is achieved with few lines of code.

Library Compatibility Chart

Dynamic link libraries can be compiled for both Windows 32-bits and Windows 64-bits, having also different Calling Conventions.

Several options are available when compiling libraries for Windows 32bits operating system. In this case, the tests were carried out with the following calling convention, more information here.

  • stdcall
  • fastcall
  • cdecl

On the other hand, in Windows 64-bits operating system, the problem has already been addressed and standardized, so we do not have the compatibility problem depending on the calling conventions, more information here.

  • Application Binary Interface (ABI)

Library usage tests in several programming languages

TThe library was compiled in the above-mentioned calling conventions and tested in the following programming languages, giving the following table of results.

Architecture Calling Convention Programming Languages
C C++ C# Java Python Visual Basic
32Bits
stdcall
+ + + - + +
fastcall + + - - - -
cdecl
+ + + - + +
64Bits ABI + + + - + +
+ Supported - Not Supported
Java has a separate DLL to be used

Library usage tests in several applications

In addition to the above languages presented, this project has been part of a research work focused on mathematical and augmented reality software. Therefore, it has been tested in the following applications giving the following compatibility chart.

Architecture Calling Convention Applications
Matlab Unity3D Excel
32Bits stdcall Not Tested Not Tested +
fastcall Not Tested Not Tested
-
cdecl Not Tested Not Tested -
64Btis ABI + + +
+ Supported      - Not Supported

Library compatibility results

  • As a result, it is seen that in 32-bit Windows operating systems the calling convention with greater compatibility is __stdcall (Since Excel in its 32bits version only supports this calling convention). The calling convention with lower compatibility is __fastcall

  • In the same way, in 64bit systems, complete compatibility is observed.

  • Libraries to be used in programming language JAVA has its own method of library generation that works completely for both 32-bits and 64-bits.

Recommendation

Although __stdcall is the one with the greatest compatibility (by a little), in the library generation decorators are added in the call to the functions creating modified names towards the functions, you can check the names of the functions depending on the calling convention here, so (Unless strictly necessary) the use of calling convention __cdecl is recommended, which retains the name of the functions.

Clone this wiki locally