I agree with Kevin here. Phil's example of putting printf's between two
points in the program isn't guaranteed to do the "correct" thing on
UNIX, either.
Anyone using printf in that way is writing incorrect code.

On Fri, 2007-09-21 at 20:47 -0700, Kevin Klues wrote:
> I guess saying that  "printf is part of the standard C library, not
> affiliated with any
> particular operating system" probably needs a little clarification.
> This library was of course first designed for unix, but has also been
> used in other OSs since.  TinyOS is no different.
> 
> Kevin
> 
> On 9/21/07, Kevin Klues <[EMAIL PROTECTED]> wrote:
> > I don't seen anything in 'man 3 printf' that implies that it has to be
> > a blocking operation.  In fact the manual shouldn't imply this.
> > printf is part of the standard C library, not affiliated with any
> > particular operating system.
> >
> > To implement printf() functionality for any mcu that has a libc (such
> > as msp430-libc or avr-libc) you just have to fill in the body of the
> > 'putchar' function declared in "stdio.h".  This is exactly what the
> > PrintfP component in tos/lib/printf does.  No magic..... it just
> > collects the bytes coming in via calls to putchar, packs them into
> > TInyOS serial messages, and sends them out over the USART.
> >
> > It should be left up to whatever operating system that implements it
> > to define the semantics.
> >
> > Kevin
> >
> > On 9/21/07, Philip Levis <[EMAIL PROTECTED]> wrote:
> > > On Sep 21, 2007, at 5:56 PM, Michael Schippling wrote:
> > >
> > > > Does 'regular' printf() guarantee that now?
> > > > I remember having to do fflush() if I really wanted to see something.
> > >
> > > C stdlib printf(3) does not always block. But it can block, and you
> > > can make it block on flushing the buffer.[1]  This might seem like a
> > > little nit, but it can bite you. E.g.:
> > >
> > > call Foo.x();
> > > printf("Got past Foo.x()\n");
> > > call Foo.y();
> > > printf("Got past Foo.y()\n");
> > >
> > > Phil
> > >
> > > [1] http://books.google.com/books?
> > > id=iRa-3L4jLhEC&pg=PA84&lpg=PA84&dq=printf+flush+newline
> > > +buffer&source=web&ots=dWntcq9i9J&sig=_r66dlfabrAEkJ8ltMzuRLysKj4
> > >
> >
> >
> > --
> > ~Kevin
> >
> 
> 

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to