[fpc-pascal] Linux IPC (SHM) : Getting Strange Value for shm_nattch (# of attachements)
Tom__G
tom at guilleminot.org
Thu Oct 15 12:46:02 CEST 2009
Henry Vermaak wrote:
>
> 2009/10/13 Tom__G <tom at guilleminot.org>:
>>
>> Hi,
>>
>> I try to get number of processes attached to a specific shared memory
>> segment.
>> So I read the shmctl record to retrieve this into shared memory :
>>
>> type TShmid_ds = record
>> shm_perm: TIPC_Perm; Permissions
>> shm_segsz: cint; Segment size
>> shm_atime: time_t; Last access time
>> shm_dtime: time_t; Last detach time
>> shm_ctime: time_t; Create time
>> shm_cpid: ipc_pid_t; Creator PID
>> shm_lpid: ipc_pid_t; Last operation PID
>> shm_nattch: Word; Number of attachments <--<< !
>> shm_npages: Word; Number of pages
>> shm_pages: Pointer; ?
>> attaches: pointer; ?
>> end;
>
> This definition differs from the one I've got in
> /usr/include/bits/shm.h, where shm_nattch is defined as "unsigned long
> int", so you may want to look into that. I haven't tried this myself,
> so sorry if I'm barking up the wrong tree...
>
> Henry
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
Thanks for suggestion. You may actually talk about this mismatch :
C : unsigned long int (4 bytes) : 0 to 4 294 967 295
FP : word : integers from 0 to 65535
Into my /usr/share/fpcsrc/2.2.4/rtl/unix/ipc.pp I found :
{ ----------------------------------------------------------------------
Sys V Shared memory stuff
----------------------------------------------------------------------}
Type
PShmid_DS = ^TShmid_ds;
{$ifdef linux}
{$ifdef cpux86_64}
TShmid_ds = record
shm_perm : TIPC_Perm;
shm_segsz : size_t;
shm_atime : time_t;
shm_dtime : time_t;
shm_ctime : time_t;
shm_cpid : pid_t;
shm_lpid : pid_t;
shm_nattch : culong; <--<<
__unused4 : culong;
__unused5 : culong;
end;
{$else cpux86_64}
TShmid_ds = record
shm_perm : TIPC_Perm;
shm_segsz : cint;
shm_atime : time_t;
shm_dtime : time_t;
shm_ctime : time_t;
shm_cpid : ipc_pid_t;
shm_lpid : ipc_pid_t;
shm_nattch : word; <--<<
shm_npages : word;
shm_pages : Pointer;
attaches : pointer;
end;
{$endif cpux86_64}
{$else} // FreeBSD checked
TShmid_ds = record
shm_perm : TIPC_Perm;
shm_segsz : cint;
shm_lpid : pid_t;
shm_cpid : pid_t;
shm_nattch : cshort; <--<<
shm_atime : time_t;
shm_dtime : time_t;
shm_ctime : time_t;
shm_internal : pointer;
end;
{$endif}
My hardware here is x86 (not x86_64).
--
View this message in context: http://www.nabble.com/Linux-IPC-%28SHM%29-%3A-Getting-Strange-Value-for-shm_nattch-%28--of-attachements%29-tp25874304p25906459.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
More information about the fpc-pascal
mailing list