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]

print and mutex


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


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