This is the mail archive of the ecos-discuss@sources.redhat.com 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]

Re: A query regarding cyg_mutex_lock in ecos-2.0


>>>>> "Santanu" == Santanu Chatterjee <thisissantanu@gmail.com> writes:

    <snip>

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

It is just an example. In fact by default the C library is thread-safe
anyway so the mutex is redundant, but this behaviour is controlled by
a configuration option CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS.

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

There have been a number of updates to the synthetic target since the
2.0 release, to cope with changes in the toolchain and apparent
problems with the Linux kernel on some processors. You may want to try
the current version from anoncvs, see
http://ecos.sourceware.org/anoncvs.html

Bart

-- 
Bart Veer                       eCos Configuration Architect
http://www.ecoscentric.com/     The eCos and RedBoot experts


-- 
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]