Unix Programming - shmget question.

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > June 2007 > shmget question.





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 shmget question.
Vasudev

2007-06-18, 7:23 am

I need to have n number of dynamically allocated shared memory segment
between my programs, since I dont know in advance howmany shared
memory segment I will be requiring I am allocating the segment using a
brute force, as shown below.

// returns -1 on failure, else Shared memory ID
int getNextSHSegment()
{
int key = 0;
int shmid = 0;

do
{
shmid = shmget(key, KILOBYTE, IPC_CREAT | 0644);
key ++;
key %= MAX_INT;
} while(shmid == -1)

return shmid;
}

Is this the right way to do it? any suggestions???

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com