Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Mutex seems failed to works

Altera_Forum
Honored Contributor II
850 Views

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