Hi,
I want to write a package where I would use
shared memory for some vectors
Any suggestion is appreciated...
I wonder if the right approach would be to
modify add a modified version of the
allocVector(SEXPTYPE type, int length) function
specifically
shared_mem_id = shmget(shared_mem_key,
SHM_SIZE,
IPC_CREAT);
shared = (SEXP) shmat(shared_mem_id, (void *)0, 0);
my_allocVector(SEXPTYPE type, int length, SEXP
shared) {
SEXP s=shared;
....
And erase this if:
#################################################
if(size >=
(LONG_MAX / sizeof(VECREC))-sizeof(SEXPREC_ALIGN)
||
(s =
malloc(sizeof(SEXPREC_ALIGN) + size *
sizeof(VECREC))
)
== NULL) { {
#################################################
Alex
shared mem advice
3 messages · Alex Nu, Thomas Lumley, Peter Dalgaard
On Tue, 13 Apr 2004, Alex Nu wrote:
Hi, I want to write a package where I would use shared memory for some vectors Any suggestion is appreciated...
I'd recommend looking at external pointer objects. If the developer webpage were working, that would be the place to look. I'm not sure where else there is information.
I wonder if the right approach would be to
modify add a modified version of the
allocVector(SEXPTYPE type, int length) function
specifically
shared_mem_id = shmget(shared_mem_key,
SHM_SIZE,
IPC_CREAT);
shared = (SEXP) shmat(shared_mem_id, (void *)0, 0);
No, you want the shared memory to hold the data of the vector, not the header record that the SEXP points to. If you do it this way you want to look at how memory.c:allocVector uses malloc() for large vectors. -thomas
my_allocVector(SEXPTYPE type, int length, SEXP
shared) {
SEXP s=shared;
....
And erase this if:
#################################################
if(size >=
(LONG_MAX / sizeof(VECREC))-sizeof(SEXPREC_ALIGN)
||
(s =
malloc(sizeof(SEXPREC_ALIGN) + size *
sizeof(VECREC))
)
== NULL) { {
#################################################
Alex
______________________________________________ R-devel@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
Thomas Lumley Assoc. Professor, Biostatistics tlumley@u.washington.edu University of Washington, Seattle
Thomas Lumley <tlumley@u.washington.edu> writes:
On Tue, 13 Apr 2004, Alex Nu wrote:
Hi, I want to write a package where I would use shared memory for some vectors Any suggestion is appreciated...
I'd recommend looking at external pointer objects. If the developer webpage were working, that would be the place to look. I'm not sure where else there is information.
http://www.stat.uiowa.edu/~luke/R is a good guess. Apart from that, there's some relatively simple usage of such things in the tcltk package.
O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907