This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

concurrency issue - eCos 2 (not the latest and greatest version)


This seems so simple that I am embarrassed to ask for assistance but I have
a situation that is troubling me and was wondering if any concurrency
experts out there could give me a clue as to why this would occur. 

As you will see below the returned value (val3) is supposed to be the number
of milliseconds converted from clocks ticks but I am getting weird arbitrary
values shown by the diag_printf function for the val3 value. (More
discussion at end of email too)

Please note that the diag_printf(...) logs messages out to our debug
console.

Here is some psuedo code that should give you the idea of what the code
does:

//regular function in code file
void convertTicks2Milliseconds (int val1, 
					  struct cyg_resolution_t *val2, 
					  int *val3){

	//do conversion of clock ticks and store conversion result like so: 
	
	*val3 = ((val1 * val2->dividend)/val2->divisor)/1000000;

	diag_printf("show value of *val3 using %u \n", *val3); 
}

//thread task in code file that calls convertTicks2Milliseconds()
void udpTxTask(){
	unsigned int m = 0;

	struct ccr = cyg_get_resolution(...);
	
	while(1){
		t = cyg_current_time();

		convertTicks2Milliseconds(t, &ccr, &m);

		diag_printf("show value of m using %u \n", m);
	}

} 

Now because both all of these functions are using local variables and
function arguments (I believe) then the thread stack should contain its own
copies and therefore not be subject to inter-thread data corruption correct?
If you do the conversion and call diag_printf() from the thread task
function the correct value is printed to the debug console. This symptom (to
me) immediately points to the diag_printf is having its value stomped on but
using a mutex lock around the function call produces the same result. I know
your first reaction is load it up in GDB and see what happens but our
platform doesn't have GDB so any insight you may provide would be much
appreciated.


Thanks,

Kevin

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]