lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Debug code


From: Marc Boucher
Subject: Re: [lwip-users] Debug code
Date: Sun, 9 Mar 2003 08:39:20 -0600
User-agent: Mutt/1.5.1i

On Sun, Mar 09, 2003 at 02:34:54AM +0100, Leon Woestenberg wrote:
> 
> ----- Original Message -----
> From: "Marc Boucher" <address@hidden>
> 
> > > DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(local_port)));
> > >#endif
> >
> > Btw such debug contructs are also very problematic on systems where
> multiple
> > tasks simultaneously generate debug output, since other messages can end
> up
> > being inserted between the multiple print calls resulting in mixed /
> > confusing lines.
> >
> > Better would be to print everything at once using a
> > "lwip_bind(%d, addr=%s port=%u)\n" format string with some
> inet_addr()-like
> > function (minus re-entrancy issues) or macro/token to handle IP address
> > formatting.
> >
> This is not generally true. If the OS can switch tasks pre-emptively, and
> printf does not
> lock the scheduler, the printf()ing task can simply be switched from the CPU
> and a new
> printf()ing task can be switched in.
> 
> I have solved this by having DEBUGF lock the scheduler, call printf(),
> unlock the scheduler.
> 
> Leon.

My point was that using multiple DEBUGF / ip_addr_debug_print / printf calls
to generate a single line of output is problematic on systems where
other tasks can generate output at the same time. Adding locking to
protect each call doesn't solve this problem.

Marc




reply via email to

[Prev in Thread] Current Thread [Next in Thread]