[comp.lang.c] More On Shared Memory Problem

staggers@casbah.acns.nwu.edu (Ken Staggers) (06/06/91)

Here's a little bit more detail on the program..note that I have changed
the name of create() to pcbcreate() as a net suggestion, but it didnt
help.  Exec-ing is not a problem since its not one of processes that is
having trouble, its the main program.


main()
  Create shared memory
  Access shared memory
  Attach shared memory
  Initialize shared memory
  memorydump()
  execution()

execution()
  Access shared memory
  Attach shared memory
  if (fork()== Parent)  /* Start process1 */
    pcbcreate()
  else /* fork= child */
    kill( childpid, SIGSTOP);  /* Dont run, halt self, let me schedule you */
    execl()

  if (fork()== Parent) /* start process 2 */
    pcbcreate()
  else /* fork= child */
    kill( childpid, SIGSTOP);  /* Dont run, halt self, let me schedule you */
    execl()

  if (fork()== Parent) /* start process 3 */
    pcbcreate()
  else /* fork= child */
    kill( childpid, SIGSTOP);  /* Dont run, halt self, let me schedule you */
    execl()

  if (fork()== Parent) /* start process 4 */
    pcbcreate()
  else /* fork= child */
    kill( childpid, SIGSTOP);  /* Dont run, halt self, let me schedule you */
    execl()

pcbcreate()
  Access shared memory
  Attach shared memory  <---- This is where the "TOO MANY FILES OPEN" error
                              occurs.

memorydump()
  Access shared memory
  Attach shared memory
  print out contents of all shared memory


main() is in p1.c
execution() is in execution.c
pcbcreate() and memorydump() are in syscall.c


I found out that the exec does detach, but since my running processes 1-4
right now are just counting loop, printing out a message every 100000 counts,
they, internally, dont access shared memory.

I issue no file open commands...if I issue a createsem(), a function is syscall
which initializes a semaphore and stores a string inside it, after memorydump()
but before execution() in main(), then createsem() generates the same error,
too many files open.

Any hints or suggestions would be appreciated.  thanks in advance.

--Ken

p.s. this is on an encore multimax using 4.3 BSD (UMAX)