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: Optimal timing slice , Thread qn


On Wed, Jan 19, 2005 at 02:00:35PM -0800, steve smith wrote:
> Thanks Andrew. I've understood your mail,However if we remove both
> yield in write and read threads : Why is it that only the write thread
> gets to run. Shouldn't the flow be : write runs.. releases mutex..and
> assuming data came for the serial port meantime, read should get the 
> control and run ...release mutex ....give control to write ...so on.

Why should read get control? 

> Anyhow to answer your question: I thought I needed a mutex for printf
> as its mentioned in the documentation that C Library functions like
> printf need to be protected by mutex.

You are only using printf in the read function so there is nothing to
protect if from! Also, i was right about not needing a mutex around
printf in most conditions. Go googling for "jifl printf mutex" and you
will find some post in may/june 2000 about this.

 2nd reason is that I thought I
> needed a mutex to protect the serial port resource from simultaneous
> read and write. Is this a wrong/unnecessary use of mutex?

This is wrong.

        Andrew



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