EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Should I really increase OS_MUTEXCNT to exit forever loop?

Started by janii June 25, 2013
Our embedded target board is ARM7 based Microcontroller.  We used Keil
tools, which include Keil RTX-RTOS.

/* Filename: RTX_lib.c */

static U32 nr_mutex;

int _mutex_initialize (OS_ID *mutex) { /* Allocate and initialize a system
mutex. */

if (nr_mutex >= OS_MUTEXCNT) 
{ /* If you are here, you need to increase the number OS_MUTEXCNT. */ 
   for (;;); 
} 

*mutex = &std_libmutex[nr_mutex++]; 
mutex_init (*mutex); return (1);
}


/* Filename: RTX_config.c */

// Standard library system mutexes
// ===============================
// Define max. number system mutexes that are used to protect
// the arm standard runtime library. For microlib they are not used.
#ifndef OS_MUTEXCNT 
   #define OS_MUTEXCNT 17
#endif

When I run from reset, I'm stuck in for(;;); line above. I hover on
nr_mutex and value for nr_mutex is shown in the debugger as 0x80008000. How
is this number getting assigned to nr_mutex?

How to resolve this issue?

Thank you!
	   
					
---------------------------------------		
Posted through http://www.EmbeddedRelated.com
janii wrote:

> Our embedded target board is ARM7 based Microcontroller. We used Keil > tools, which include Keil RTX-RTOS. > > /* Filename: RTX_lib.c */ > > static U32 nr_mutex; > > int _mutex_initialize (OS_ID *mutex) { /* Allocate and initialize a system > mutex. */ > > if (nr_mutex >= OS_MUTEXCNT) > { /* If you are here, you need to increase the number OS_MUTEXCNT. */ > for (;;); > } > > *mutex = &std_libmutex[nr_mutex++]; > mutex_init (*mutex); return (1); > } > > > /* Filename: RTX_config.c */ > > // Standard library system mutexes > // =============================== > // Define max. number system mutexes that are used to protect > // the arm standard runtime library. For microlib they are not used. > #ifndef OS_MUTEXCNT > #define OS_MUTEXCNT 17 > #endif > > When I run from reset, I'm stuck in for(;;); line above. I hover on > nr_mutex and value for nr_mutex is shown in the debugger as 0x80008000. > How is this number getting assigned to nr_mutex? > > How to resolve this issue?
How does the rest of memory look? Is it just nr_mutex, or are things being clobbered generally? Mel.

The 2024 Embedded Online Conference