This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
print and mutex
- From: steve smith <mister dot steve dot smith at gmail dot com>
- To: ecos-discuss at sources dot redhat dot com
- Cc: mister dot steve dot smith at gmail dot com
- Date: Tue, 18 Jan 2005 09:48:14 -0800
- Subject: [ECOS] print and mutex
- Reply-to: steve smith <mister dot steve dot smith at gmail dot com>
Hey All,
Suppose printf is writing several bytes to the internal USART on a
micro and an external interrupt of highest priority occurs; does
printf yield to that interrupt or does ISR get delayed until printf
completes?
Also in the example code twothreads.c
there is comment saying /* note: printf() must be protected by a call
to cyg_mutex_lock() */
code is:
cyg_mutex_lock(&cliblock); {
printf("Thread %d: and now a delay of %d clock ticks\n",
message, delay);
}
cyg_mutex_unlock(&cliblock);
Why should the printf be protected?. is it because two threads try ot
use the same USART to do printf? and hence the USART resource should
only be used by one thread at a time?
thanks
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss