[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] Problem



Hi!

I am having a problem with a GEM program and the memory protection. Perhaps
someone could tell what's wrong.

A GEM application starts a "thread" via Pexec(7)/Pexec(104). The child
process must be a GEM application too, so I have used one of the latest
GEMLib versions (with "MT support").

The function that starts the thread looks as follows (it's a variation of
mintlib's tfork()):

static long
tfork(void *startup, char *proctitle)
{
      BASEPAGE *new;
      long flags, pid;

      flags = (F_FASTLOAD | F_ALTLOAD | F_ALTALLOC);

      new = (BASEPAGE *)Pexec(7L, (void *)flags, "", 0L);
      if ((long)new < 0)
            new = (BASEPAGE *)Pexec(5L, 0L, "", 0L);

      if ((long)new <= 0)
      {
            if (!(long)new)
                  return -ENOMEM;
            return (long)new;
      }

      Mshrink(new, 8192L);

      new->p_hitpa = (char *)((long)new + 8192L);
      new->p_tbase = startup;

      pid = Pexec(104, proctitle, (char *)new, 0L);

      Mfree((long)new->p_env);
      Mfree((long)new);

      return pid;
}

The actual child process code goes as follows:

static short child_global[16];

static void
child_proc(BASEPAGE *bp)
{
      short apid;

      apid = mt_appl_init(child_global);

      if (apid >= 0)
      {
            if (setjmp(jbuf) == 0)
            {
                  Psignal(SIGTERM, sterm);

                  if (apid >= 0)
                  {
                        mt_menu_register(apid, "  Child proc",
child_global);

                        /* ...
                         * Here comes some GEM stuff the program has to do
                         * ...
                         */
                   }
            }
            mt_appl_exit(child_global);
       }

       Pterm(0);
}

The child_proc() starts normally, calls the mt_appl_init(), but never
returns from there, because a bus error occurs then. The parent process uses
the same code at the begin of the main() function, except that different
array is used for global array, and it works. It may be that I am doing
something wrong here, because I am not very familiar with GEMLib.

However, some time ago I wrote the same program in assembler (I am now
trying to recode it in C, that is) using my own, statically linked assembler
library functionally similar to the GEMLib, and also with MT support. The
program worked, but since a version of MiNT it stopped working with memory
protection. The symptom is the same: bus error short after starting the
child code. So it may be even a problem with the kernel, I don't know.

Anyone?

--
CVV
Konrad M.Kokoszkiewicz, http://draco.atari.org

** Ea natura multitudinis est, aut seruit humiliter, aut superbe dominatur.
** Taka to już natura pospólstwa, albo służalczo się płaszczy,
** albo bezczelnie się panoszy. (T. Liuius XXIV, 25).