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

help on crash (2)



Hallo,

during testing I found a possible reason for the crash desribted my last email.
The problems seems to be the memcpy() function inside the rtmodule for me.

The parts of code are attached. What's wrong with it??

Thanks	Olaf


typedef struct {
  bool inuse;			/* only used inside shm */
  bool valid;
  double um[65536];
} shm_slut_t;


int inline shm_get_sensorLUT(shm_slut_t *slut_dest)
{
  unsigned long flags;

  /* check of correctness of the argument */
  ......

  if(!shm_slut->inuse) {
    RTREG_DEBUG(4, "Get Sensor LUT from Shm\n");

    /* critical section, disable interrrupts */
    rtl_hard_savef_and_cli(flags);

    shm_slut->inuse = true;

    memcpy((void *)slut_dest, (void *)shm_slut, sizeof(shm_slut_t));

    shm_slut->inuse = false;

    /* restore interrupts */
    rtl_hard_restore_flags(flags);

    return 0;
  } else {
    RTREG_DEBUG(4, "Sensor LUT is in use, ignored !\n");

    return -EBUSY;
  }
}


void *thread_code(void *param)
{
  register int r;
  static char buf[24];
  shm_slut_t slut;

    while(1) {
	pthread_wait_np();

	shm_get_sensorLUT(&slut);
	
	for(r=0; r < NI_PCI_MIO_XE10_RES + 1; r++)  {
	    if((r+1) % 4096 == 0 || r == 0) {
		sprintf(buf, "%d\t%4.4f\n",r, slut.um[r]);
		rtf_put(THREAD_FIFO, buf, sizeof(buf));
	    }
	}

    }
    
    return 0;
}