(Sorry for all the different venues for this, I’ve had this conversation piecewise with many of you already)
I’m trying to write the equivalent julia code for the following Cython code:
https://github.com/mapd/pymapd/blob/01019c6a48814a44644499bf4053f46e488e7ac6/pymapd/shm.pyx#L31-L52
I receive the following from calling an external API, where I’m trying to IPC using shared memory:
julia> tdf.sm_handle
4-element Array{UInt8,1}:
0x9b
0x76
0x9a
0x18
julia> tdf.sm_size
93856
I’ve gotten this far:
shmkey = reinterpret(UInt32, tdf.sm_handle)[1]
shmid = ccall((:shmget, "libc"), Cint, (Cuint, Int32, Int32), shmkey, tdf.sm_size, 0)
ptr = ccall((:shmat, "libc"), Ptr{Void}, (Cint, Ptr{Void}, Cint), shmid, C_NULL, 0)
julia> ptr
Ptr{Void} @0x00007f67fc7b4000
I believe the code above is equivalent to the Cython code, but I’m not quite sure. Would take any help there. But ultimately, my question is, if ptr
is actually the location of the first element of the array of shared memory, how do I bring all of the data from shared memory into Julia?
When I debug the Cython code, pabuff
is intermingled with ASCII text I recognize, along with a bunch of 0x00
and the like in between all the text. But not having any real experience with C and shared memory, I’m stuck between how I take the shared memory ID I’m passed and actually read the data into julia.