Skip to content

Commit

Permalink
Merge pull request #1709 from ghaerr/slspeedup
Browse files Browse the repository at this point in the history
[kernel] Speed up TTY output processing
  • Loading branch information
ghaerr authored Sep 11, 2023
2 parents 51b8bcc + 62d104f commit 5eaea47
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
15 changes: 8 additions & 7 deletions elks/arch/i86/drivers/char/ntty.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ void tty_release(struct inode *inode, struct file *file)
*
* while (tty->outq.len > 0) {
* ch = tty_outproc(tty);
* write_char_to_device(device, (char)ch);
* write_char_to_device(device, ch);
* cnt++;
* }
*
*/
int tty_outproc(register struct tty *tty)
{
int t_oflag; /* WARNING: highly arch dependent, termios.c_oflag truncated to 16 bits*/
int t_oflag; /* WARNING: termios.c_oflag truncated to 16 bits */
int ch;

ch = tty->outq.base[tty->outq.tail];
Expand Down Expand Up @@ -247,7 +247,7 @@ int tty_outproc(register struct tty *tty)
break;
#endif
case '\t':
if ((t_oflag & TABDLY) == TAB3) {
if ((t_oflag & TABDLY) == XTABS) {
ch = ' '; /* Expand tabs to spaces */
tty->ostate = 0x20 + TAB_SPACES - 1;
}
Expand All @@ -267,7 +267,7 @@ static void tty_echo(register struct tty *tty, unsigned char ch)
if ((tty->termios.c_lflag & ECHO)
|| ((tty->termios.c_lflag & ECHONL) && (ch == '\n'))) {
if ((ch == tty->termios.c_cc[VERASE] || ch == tty->termios.c_cc[VERASE2])
&& (tty->termios.c_lflag & ECHOE)) {
&& (tty->termios.c_lflag & ECHOE)) {
chq_addch(&tty->outq, '\b');
chq_addch(&tty->outq, ' ');
chq_addch(&tty->outq, '\b');
Expand All @@ -290,10 +290,11 @@ size_t tty_write(struct inode *inode, struct file *file, char *data, size_t len)

i = 0;
while (i < len) {
s = chq_wait_wr(&tty->outq, file->f_flags & O_NONBLOCK);
s = chq_wait_wr(&tty->outq, (file->f_flags & O_NONBLOCK) | i);
if (s < 0) {
/* FIXME EAGAIN not returned, cycle required on telnet nonblocking terminal */
if (s == -EINTR || s == -EAGAIN) {
tty->ops->write(tty);
wake_up(&tty->outq.wait);
schedule();
continue;
Expand All @@ -302,10 +303,10 @@ size_t tty_write(struct inode *inode, struct file *file, char *data, size_t len)
i = s;
break;
}
chq_addch_nowakeup(&tty->outq, get_user_char((void *)data++));
tty->ops->write(tty);
chq_addch_nowakeup(&tty->outq, get_user_char(data++));
i++;
}
tty->ops->write(tty);
wake_up(&tty->outq.wait);
return i;
}
Expand Down
4 changes: 2 additions & 2 deletions elks/fs/read_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int sys_read(unsigned int fd, char *buf, size_t count)
fop = file->f_op;
if (fop->read) {
retval = (int) fop->read(file->f_inode, file, buf, count);
schedule();
schedule(); // FIXME removing these slows down localhost networking
}
}
return retval;
Expand Down Expand Up @@ -129,7 +129,7 @@ int sys_write(unsigned int fd, char *buf, size_t count)

}
written = (int) fop->write(inode, file, buf, count);
schedule(); // FIXME should this be here?
schedule(); // FIXME removing these slows down localhost networking
}
}
return written;
Expand Down
11 changes: 4 additions & 7 deletions elks/include/linuxmt/chqueue.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* chqueue.h (C) 1997 Chad Page, rewritten Greg Haerr Oct 2020 */

#ifndef __LINUXMT_CHQ_H
#define __LINUXMT_CHQ_H

/* chqueue.h (C) 1997 Chad Page, rewritten Greg Haerr Oct 2020 */

struct ch_queue {
unsigned char *base;
int size; /* doesn't have to be power of two*/
Expand All @@ -11,15 +11,12 @@ struct ch_queue {
};

extern void chq_init(register struct ch_queue *,unsigned char *,int);
/*extern void chq_erase(register struct ch_queue *);*/
extern int chq_wait_wr(register struct ch_queue *,int);
extern int chq_wait_rd(register struct ch_queue *,int);
extern void chq_addch(register struct ch_queue *,unsigned char);
extern void chq_addch_nowakeup(register struct ch_queue *,unsigned char);
extern int chq_delch(register struct ch_queue *);
extern int chq_peekch(register struct ch_queue *);
/*extern int chq_full(register struct ch_queue *);*/

extern int chq_wait_rd(register struct ch_queue *,int);
extern int chq_getch(register struct ch_queue *);
/*extern int chq_full(register struct ch_queue *);*/

#endif

0 comments on commit 5eaea47

Please sign in to comment.