Unix Programming - index array, shared in memory

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2004 > index array, shared in memory





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author index array, shared in memory
b83503104

2004-10-02, 9:13 pm

I want to create an index and put it in memory, and allow it to be
read by multiple programs (processes).
The index table looks like this:
1 231
2 91
3 147
....

There are million items, each row uses 2 int, so total size about
10MB. I only know how to create this in memory and use it by the SAME
program which created it. I have no idea how I could let it stay in
memory and be used by OTHER programs (and more than one at one time).
Thanks
Dragan Cvetkovic

2004-10-02, 9:13 pm

b83503104@yahoo.com (b83503104) writes:

> I want to create an index and put it in memory, and allow it to be
> read by multiple programs (processes).
> The index table looks like this:
> 1 231
> 2 91
> 3 147
> ...
>
> There are million items, each row uses 2 int, so total size about
> 10MB. I only know how to create this in memory and use it by the SAME
> program which created it. I have no idea how I could let it stay in
> memory and be used by OTHER programs (and more than one at one time).
> Thanks


Put it into shared memory. Use shmget(), shmat() and friends.

HTH, Dragan


--
Dragan Cvetkovic,

To be or not to be is true. G. Boole No it isn't. L. E. J. Brouwer

!!! Sender/From address is bogus. Use reply-to one !!!
Andrei Voropaev

2004-10-02, 9:13 pm

["Followup-To:" header set to comp.unix.programmer.]
On 2004-10-01, Dragan Cvetkovic <me@privacy.net> wrote:
> b83503104@yahoo.com (b83503104) writes:
>
>
> Put it into shared memory. Use shmget(), shmat() and friends.


Maybe simply put it into file and then mmap it in your applications. man
mmap.

Andrei
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com