Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

Two processors sharing the same mutex, one with linux the otherone without

Hello to everyone! I am struggling to make this work, let me share my efforts to make the mutex work between a NIOS2-MMU Linux and a NIOS2- w/o LINUX

My NIOS2 NO-LINUX is running this program:


int main()
{
  alt_putstr("Proc 2!\n");
  /* get the mutex device handle */
  alt_mutex_dev* mutex = altera_avalon_mutex_open( "/dev/mutex" );
  /* acquire the mutex, setting the value to one */
  altera_avalon_mutex_trylock( mutex, 1 );
  while(1){
  if(altera_avalon_mutex_is_mine(mutex))
      {
          usleep(100);
          alt_printf("%x\n", IORD_32DIRECT(SHARED_MEM_BASE, 0x00));
    }
  altera_avalon_mutex_unlock( mutex );
  }
  return 0;
}
My Device Driver of the MMU Linux is written here: http://pastebin.com/gwlfqawv

However it is'nt working. When i boot my Linux it says that my Mutex

is at the adress e0000001c4, i dont understand why it has this "e" in

the front of the adress? Also it isn't locking because when i lock in

Linux i still can lock/unlock at NIOS2-NOLINUX

outl(0x00000001, shmem.mutex);

if (inl(shmem.mutex) == 0x00000001) {printk(KERN_INFO "locked\n"); return 1;}

I get the locked message at Linux, however the mutex isnt locking.

Any help is appreciated

2 Replies