Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
777 Views

Mutex seems failed to works

Hi, 

 

i got other problem with my mutex. This is my code for two slaves processor (assume the OnChip address is fine ): 

 

 

 

 

#include "sys/alt_stdio.h"# include "system.h"# include "stdio.h"# include "alt_types.h"# include "io.h"# include "altera_avalon_mutex.h" # define OnChip 0x00007000 int main() { alt_mutex_dev *s1; # ifdef MUTEX_BASE s1 = altera_avalon_mutex_open("/dev/mutex");# endif printf("NIOS %d is waiting for control signal\n",ALT_CPU_CPU_ID_VALUE); // waiting for control signal while(!IORD(OnChip,0x00)); while(altera_avalon_mutex_trylock(s1,ALT_CPU_CPU_ID_VALUE)); // printing data printf("NIOS %d captured Mutex \n",ALT_CPU_CPU_ID_VALUE); altera_avalon_mutex_unlock(s1); return 0;  

 

and this is my code for my top processor 

# include "sys/alt_stdio.h"# include "system.h"# include "stdio.h"# include "alt_types.h"# include "io.h"# include "altera_avalon_mutex.h" # define OnChip 0x00007000 int main() { printf("NIOS top gives control signal\n"); IOWR(OnChip,0x00,1); while(1); return 0; }  

 

 

My expectation should be : 

 

NIOS 1 captured mutex 

NIOS 2 captured mutex  

 

however the result is out of my expectation, the result shown in attachment. 

 

here the text version of my result : 

 

NNIIOOSS 22 ccaappptuuurreedd muutttexx 

 

 

Need for advice. Thanks
0 Kudos
0 Replies
Reply