200
200
return attach_shmem(key, pp);
203
// Mark the shared memory segment so it will be released after
204
// the last attached process detaches or exits.
205
// On Mac OS X and some other systems, not doing this causes
206
// shared memory leaks if BOINC crashes or exits suddenly.
207
// On Mac OS X and some other systems, this command also
208
// prevents any more processes from attaching (by clearing
209
// the key in the shared memory structure), so BOINC does it
210
// only after we are completey done with the segment.
203
211
int destroy_shmem(key_t key){
204
212
struct shmid_ds buf;
271
// For debugging shared memory logic
272
// For testing on Apple, Linux, UNIX systems with limited number
273
// of shared memory segments per process and / or system-wide
274
// Mac OS X has a default limit of 8 segments per process, 32 system-wide
276
void stress_shmem(short reduce_by) {
280
'BNC0', 'BNC1', 'BNC2', 'BNC3', 'BNC4', 'BNC5', 'BNC6', 'BNC7',
281
'BNC8', 'BNC9', 'BNCA', 'BNCB', 'BNCC', 'BNCD', 'BNCE', 'BNCF'
285
if (reduce_by > 16) reduce_by = 16;
287
// Tie up 5 of the 8 shared memory segments each process may have
288
for (i=0; i<reduce_by; i++) {
289
retval = create_shmem(key[i], 1024, 0, &shmaddr[i]);
290
id = shmget(key[i], 0, 0);
291
// Mark it for automatic destruction when BOINC exits
293
retval = shmctl(id, IPC_RMID, 0);
265
const char *BOINC_RCSID_f835f078de = "$Id: shmem.C 12138 2007-02-22 09:33:08Z ballen $";
300
const char *BOINC_RCSID_f835f078de = "$Id: shmem.C 13053 2007-06-29 23:47:41Z charlief $";