Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* shared memory
@ 1997-10-18  4:00 Dean Hougen
  1997-10-18  4:00 ` Dirk Grunwald
  0 siblings, 1 reply; 4+ messages in thread
From: Dean Hougen @ 1997-10-18  4:00 UTC (permalink / raw)



Is it me, or is it DU4.0b?  (It could well be me; I haven't done much shared
memory stuff in the past.)

I want to create two shared memory areas for several processes to share.  I
use the following code:

  /* create shared memory for use as a buffer */
  buffer_size= sizeof(item)*num_b;
  if (buffer_id= shmget (IPC_PRIVATE, buffer_size, SHM_FLAGS) == -1){
    printf ("Failed to open shared memory for buffer\n");
    exit(-1);
  }
  if ((buffer_ptr = (char *) shmat (buffer_id, 0, 0)) == (char *) -1){
    printf ("Failed to assign shared memory pointer for buffer\n");
    exit(-1);
  }

  /* create shared memory for counting */
  count_size= sizeof(production);
  if (count_id= shmget (IPC_PRIVATE, count_size, SHM_FLAGS) == -1){
    printf ("Failed to open shared memory for counter\n");
    exit(-1);
  }
  if ((count_ptr = (char *) shmat (count_id, 0, 0)) == (char *) -1){
    printf ("Failed to assign shared memory pointer for counter\n");
    exit(-1);
  }

  printf ("buffer_id is %d\t count_id is %d\n", buffer_id, count_id);

When I run it, it tells me that both buffer_id and count_id are 0 and
proceeds to garble things up.  Shouldn't I be getting separate ID's for
these two memory regions?

I did the obvious workaround -- using one shared memory region for both
purposes and using an offset for one pointer -- and everything works fine.
I just don't understand why it won't let me use two separate regions.

Thanks in advance for your 2^6 bits of advice.

Dean Hougen
--
"I've been dazed and confused for so long it's not true." - Led Zepplin



^ permalink raw reply	[flat|nested] 4+ messages in thread
* Shared Memory
@ 1994-05-24 13:45 Gary Whitehead
  1994-05-25  1:59 ` Chris Kevlahan
  0 siblings, 1 reply; 4+ messages in thread
From: Gary Whitehead @ 1994-05-24 13:45 UTC (permalink / raw)


I've moved some code to OSF/1 from ULTRIX which does the following:

{
    int mem_id;
    char *mem_pool;

    mem_id = shmget(1, 1024 * 1024, 00666 | IPC_CREAT | IPC_EXCL);
    mem_pool = (char *)shmat(mem_id, 0, 0);    



When I run this the first time from bootup, it fails. mem_pool is -1 and 
errno is set to 24 (EMFILE).

However, when I run it again, it works fine. When I remove the shared 
memory area with 'ipcrm -m' and run it again, it works also. It only 
fails after a reboot. On ULTRIX, it always worked.

I am on OSF/1 1.3A and have tried it on various DEC 3000 AXP machines.

Any ideas would be much appreciated,

Thanks,
Gary Whitehead



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1997-10-18  4:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-10-18  4:00 shared memory Dean Hougen
1997-10-18  4:00 ` Dirk Grunwald
  -- strict thread matches above, loose matches on Subject: below --
1994-05-24 13:45 Shared Memory Gary Whitehead
1994-05-25  1:59 ` Chris Kevlahan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox