termios+PTY=real-time killer? (was Re: Interrupt Latency on PPC)
Correo Fernando-ruiz (E-mail)
correo at fernando-ruiz.com
Wed Nov 21 23:43:20 UTC 2001
> -----Mensaje original-----
> De: till at MAILBOX.SLAC.Stanford.EDU
> [mailto:till at MAILBOX.SLAC.Stanford.EDU]En nombre de Till Straumann
> Enviado el: martes, 20 de noviembre de 2001 19:51
> Para: Fernando RUIZ CASAS
> CC: Thomas.Doerfler at imd-systems.de; fernando.ruiz at ctv.es;
> rtems-users at oarcorp.com
> Asunto: Re: termios+PTY=real-time killer? (was Re: Interrupt
> Latency on
> PPC)
>
>
> Fernando RUIZ CASAS wrote:
>
> > Well,
> > If the problem is termios this is a problem that other
> person must change.
> >
>
> Hmm - the PTY driver still needs to enable polled or task driven mode.
> I believe it's in 'interrupt driven mode' by default (although the pty
> device doesn't really generate any IRQ). Out of my head, I can't tell
> which one (polled vs. task) is better suited for PTY - does
> anybody know?
>
-------- PTY.C ---------------
...
/*-----------------------------------------------------------*/
/* Write Characters into pty device */
/*-----------------------------------------------------------*/
static int
ptyPollWrite(int minor, const char * buf,int len) {
int count;
if (minor<MAX_PTYS) {
if (ptys[minor].socket<0) return -1;
count=write(ptys[minor].socket,buf,len);
} else {
count=-1;
};
return count;
}
/*-----------------------------------------------------------*/
static int
ptyPollRead(int minor) {
int result;
if (minor<MAX_PTYS) {
if (ptys[minor].socket<0) return -1;
result=read_pty(minor); /* ONE CHAR ONLY */
return result;
};
return -1;
}
/*-----------------------------------------------------------*/
static const rtems_termios_callbacks pty_poll_callbacks = {
ptyPollInitialize, /* FirstOpen*/
ptyShutdown, /* LastClose*/
ptyPollRead, /* PollRead */
ptyPollWrite, /* Write */
ptySetAttributes, /* setAttributes */
NULL, /* stopRemoteTX */
NULL, /* StartRemoteTX */
0 /* outputUsesInterrupts */
};
/*-----------------------------------------------------------*/
const rtems_termios_callbacks * pty_get_termios_handlers(int polled) {
return &pty_poll_callbacks; /* Always polled */
}
/*-----------------------------------------------------------*/
---- END OF SOURCE --------------
With these very SIMPLE POLLED routines I can write/read in a termios
terminal implementation.
I don't use INTERRUPT mode. ONLY polling.
Polled mode is more stable because the interrupts are enabled and the
termios code
don't lock the interrupts if
...
0 /* outputUsesInterrupts */
...
BRGDS
Fernando RUIZ CASAS
home: correo at fernando-ruiz.com
work: fernando.ruiz at ctv.es
> -- Till
>
> >
> > If once this change has been made the proplem persists I
> can think about change the pty.c module
> > in order to improve with new features.
> >
> > BRGDS.
> >
> > On Mon, 19 November 2001, "Thomas Doerfler" wrote:
> >
> > > In-Reply-To: <000301c170d9$4cd02c90$7c00a8c0 at athlon1100>
> > > Content-Transfer-Encoding: 7BIT
> > > Priority: normal
> > > References: <3BF6A116.CF8A6105 at OARcorp.com>
> > > To: "Fernando RUIZ CASAS \EE-mail\"" <fernando.ruiz at ctv.es>,
> > > <fernando.ruiz at ctv.es>
> > > Delivered-To: fernando-ruiz.com%correo at fernando-ruiz.com
> > > Delivered-To: mailing list rtems-users at oarcorp.com
> > > Cc: "'Fernando RUIZ CASAS \EE-mail\''" <fernando.ruiz at ctv.es>,
> > > "'RTEMS List'" <rtems-users at oarcorp.com>
> > > Received: (cpmta 12927 invoked from network); 19 Nov 2001
> 12:40:15 -0800
> > > Received: from 208.166.120.97 (HELO www.oarcorp.com)
> > > by smtp.c007.snv.cp.net (209.228.33.204) with SMTP;
> 19 Nov 2001 12:40:15 -0800
> > > Received: (qmail 6569 invoked by uid 330); 19 Nov 2001
> 19:32:41 -0000
> > > Received: (qmail 6564 invoked from network); 19 Nov 2001
> 19:32:40 -0000
> > > Received: from unknown (HELO nixe.ISAR.net) (212.14.65.1)
> > > by 0 with SMTP; 19 Nov 2001 19:32:40 -0000
> > > Received: from zerberus.imd-systems.local
> (gate.imd-systems.de [212.14.77.47])
> > > by nixe.ISAR.net (8.9.3/8.9.3/ni-2.3) with ESMTP id UAA27899;
> > > Mon, 19 Nov 2001 20:31:40 +0100 (CET)
> > > Received: from hauptimd (hauptimd.imd-systems.local
> [192.168.64.10])
> > > by zerberus.imd-systems.local (8.9.3/8.9.3/SuSE Linux
> 8.9.3-0.1) with ESMTP id UAA17401;
> > > Mon, 19 Nov 2001 20:30:55 +0100
> > > Mailing-List: contact rtems-users-help at oarcorp.com; run by ezmlm
> > > Content-Type: text/plain; charset=US-ASCII
> > > Content-Length: 5282
> > > X-Received: 19 Nov 2001 20:40:15 GMT
> > > Content-Description: Mail message body
> > > Subject: RE: termios+PTY=real-time killer? (was Re:
> Interrupt Latency on PPC)
> > > From: "Thomas Doerfler" <Thomas.Doerfler at imd-systems.de>
> > > Organization: IMD
> > > Return-Path:
> <rtems-users-return-3870-correo=fernando-ruiz.com at oarcorp.com>
> > > Mime-Version: 1.0
> > > Date: Mon, 19 Nov 2001 20:30:35 +0100
> > > X-Mailer: Pegasus Mail for Win32 (v4.0, beta 40)
> > > Message-Id: <3BF96BEB.10576.67E7ED at localhost>
> > >
> > > Hi,
> > >
> > > > My own implementation (a very particular) ot PTY is a way to
> > > > give to shell() a tcp/ip solution but with a standard
> > > conection telnet
> > > > client.
> > > >
> > > > I couldn't think in this kind of problems when the
> > > implementation.
> > >
> > > I think it is the termios code that should be changed, (and
> > > possibly I broke it two years ago), there is really no reason
> > > to disable interrupts during polled write. I think it is easy
> > > to check, whether the device is working polled and skip irq
> > > blocking then. Please not that for task-driven mode, some irq
> > > disables may still be needed.
> > >
> > > I won't find time to change this before the next weekend, so
> > > if the problem is urgent, maybe someone else could try to
> > > solve it?
> > >
> > > Bye,
> > > Thomas.
> > >
> > > >
> > > > Fernando RUIZ CASAS
> > > > home:correo at fenando-ruiz.com
> > > > work:fernando.ruiz at ctv.es
> > > >
> > > > -----Mensaje original-----
> > > > De: Joel Sherrill [mailto:joel.sherrill at oarcorp.com]
> > > > Enviado el: sabado, 17 de noviembre de 2001 18:41
> > > > Para: Till Straumann
> > > > CC: Fernando RUIZ CASAS (E-mail); 'RTEMS List'
> > > > Asunto: Re: termios+PTY=real-time killer? (was Re: Interrupt
> > > Latency on
> > > > PPC)
> > > >
> > > >
> > > >
> > > >
> > > > Till Straumann wrote:
> > > > >
> > > > > "Fernando RUIZ CASAS (E-mail)" wrote:
> > > > >
> > > > > > Hi.
> > > > > > Is the PTY driver the pty.c file placed close to
> > > telnetd.c?
> > > > > >
> > > > > > This pty driver doesn't make any special thing with
> > > termios.
> > > > > > If the tcp/ip works fine the driver also.
> > > > > >
> > > > >
> > > > > We are talking about the very one. I agree, pty.c does not
> > > do anything
> > > > > special. However, termios [under some circumstances] calls
> > > > > pty's pollWrite() function with _Interrupts_disabled_:
> > > > >
> > > > > rtems_interrupt_disable(level);
> > > > > ...
> > > > > tty->device.write(...);
> > > > > ...
> > > > > rtems_interrupt_enable(level);
> > > > >
> > > > > Because PTY's pollWrite() does socket/IO, I guess it could
> > > even
> > > > > block! - Or am I missing something?
> > > > >
> > > > > I suppose that termios could relax its interrupt-disabling
> > > policy
> > > > > in task driven mode. PTY should then probably be run in
> > > task
> > > > > driven or polled mode.
> > > >
> > > > Another more general solution may be for there to be a PTY
> > > > server that processes requests. I don't know if having
> > > > a single task to do all PTY requests is good or bad though.
> > > >
> > > > I have a couple of more general questions.
> > > >
> > > > + Does this mean that the PTY is doing socket IO inside
> > > > an interrupt? If so, I suspect this is very dangerous.
> > > > Eric Norum should comment.
> > > > + Is the interrupt disable necessary in general?
> > > >
> > > > > -- Till
> > > > >
> > > > > >
> > > > > > Perhaps I'm speaking about other oignons.
> > > > > >
> > > > > > Fernando RUIZ CASAS
> > > > > > home:correo at fenando-ruiz.com
> > > > > > work:fernando.ruiz at ctv.es
> > > > > >
> > > > > > -----Mensaje original-----
> > > > > > De: till at MAILBOX.SLAC.Stanford.EDU
> > > > > > [mailto:till at MAILBOX.SLAC.Stanford.EDU]En nombre de Till
> > > Straumann
> > > > > > Enviado el: viernes, 16 de noviembre de 2001 2:26
> > > > > > Para: RTEMS List; joel.sherrill at oarcorp.com
> > > > > > Asunto: Re: Interrupt Latency on PPC
> > > > > >
> > > > > > Things get _really_ bad when the PTY driver is
> > > > > > heavily used. I measured IRQ latencies of ~200us
> > > > > > during quite short measurement intervals (remember,
> > > > > > we're doing statistics here). This is in the order of
> > > > > > 100 times the average.
> > > > > >
> > > > > > I guess that the problem is caused by termios.c
> > > > > > which under some circumstances calls the
> > > > > > device's 'write' callback with _IRQs_disabled_.
> > > > > > The PTY driver's write callback is a
> > > > > >
> > > > > > write(socket,...)
> > > > > >
> > > > > > outchh!
> > > > > >
> > > > > > Is there a termios expert out there who could explain
> > > > > > to me what really needs to be protected from interrupts?
> > > > > >
> > > > > > Also, shouldn't the PTY driver run in task driven
> > > > > > (as opposed to the current IRQ driven) mode?
> > > > > >
> > > > > > -----Mensaje original-----
> > > > > > De: till at MAILBOX.SLAC.Stanford.EDU
> > > > > > [mailto:till at MAILBOX.SLAC.Stanford.EDU]En nombre de Till
> > > Straumann
> > > > > > Enviado el: viernes, 16 de noviembre de 2001 2:26
> > > > > > Para: RTEMS List; joel.sherrill at oarcorp.com
> > > > > > Asunto: Re: Interrupt Latency on PPC
> > > > > >
> > > > > > Things get _really_ bad when the PTY driver is
> > > > > > heavily used. I measured IRQ latencies of ~200us
> > > > > > during quite short measurement intervals (remember,
> > > > > > we're doing statistics here). This is in the order of
> > > > > > 100 times the average.
> > > > > >
> > > > > > I guess that the problem is caused by termios.c
> > > > > > which under some circumstances calls the
> > > > > > device's 'write' callback with _IRQs_disabled_.
> > > > > > The PTY driver's write callback is a
> > > > > >
> > > > > > write(socket,...)
> > > > > >
> > > > > > outchh!
> > > > > >
> > > > > > Is there a termios expert out there who could explain
> > > > > > to me what really needs to be protected from interrupts?
> > > > > >
> > > > > > Also, shouldn't the PTY driver run in task driven
> > > > > > (as opposed to the current IRQ driven) mode?
> > > > > >
> > > > > > -- Till.
> > > >
> > > > --
> > > > Joel Sherrill, Ph.D. Director of Research &
> > > Development
> > > > joel at OARcorp.com On-Line Applications
> > > Research
> > > > Ask me about RTEMS: a free RTOS Huntsville AL 35805
> > > > Support Available (256) 722-9985
> > >
> > > --------------------------------------------
> > > IMD Ingenieurbuero fuer Microcomputertechnik
> > > Thomas Doerfler Herbststrasse 8
> > > D-82178 Puchheim Germany
> > > email: Thomas.Doerfler at imd-systems.de
> > > PGP public key available at: http://www.imd-
> > > systems.de/pgp_key.htm
> >
> > =================================
> > Fernando RUIZ CASAS
> > =================================
> > http://www.fernando-ruiz.com
> > mailto://correo@fernando-ruiz.com
> > Tel.Mov:+34-659238416
>
>
More information about the users
mailing list