[ECOS] A query regarding cyg_mutex_lock in ecos-2.0

Santanu Chatterjee thisissantanu@gmail.com
Mon Mar 14 11:15:00 GMT 2005

Hello Everybody,

I am doing a course on Embedded Technology, and as part of
my project work I have decided to use eCos and try to implement
a new scheduler for eCos.

I am very new to eCos and RTOSes in general. I was studying the
freely downloadable eCos book by Massa. For the moment, I am 
using the Linux synthetic target (Debian Sarge at home, and 
Fedora Core 1 at the University) 

Now, in the example programs that are supplied with eCos distribution, 
I was experimenting with the program twothreads.c. There it says:
(In cyg_user_start( )):
/* and now a mutex to protect calls to the C library */
cyg_mutex_t cliblock;
And in simple_program( ) thread:
    /* note: printf() must be protected by a
       call to cyg_mutex_lock() */
    cyg_mutex_lock(&cliblock); {
      printf("Thread %d: and now a delay of %d clock ticks\n",
             message, delay);
I am not sure what exactly is being protected by the mutex.
Is it protecting all calls to the C library (If so, how), or is it
just an example showing how to serialize access to a critical
region of code? For example, even if I don't unlock the mutex
in the thread above and create my own thread and make it
use 'printf', it succeeds all the time. 
Could you please clarify?

Also, there is another less important problem i am facing.
All the sample programs are running fine on both Fedora and 
Debian, except that the twothreads program is not running under 
Fedora. I get no error, but it does not print anything either (whereas
under Debian it runs just fine). Can anyone please point me to the
right direction to start looking.

I apologize if this is too trivial or if should be asking this type of
questions in some other list (please let me know where,in that case).
I am very new to ecos. So, please bear with me and
thanks in advance for your help.


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

More information about the Ecos-discuss mailing list