Re: Printing the messages through printk while using Xwindows.

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Fri Jul 28 2000 - 14:35:16 EST


On Fri, 28 Jul 2000, Russell King wrote:

> Richard B. Johnson writes:
> > This is a wee bit better because it will compile and run ;)
> >
> > print_string(char *str)
> > {
> > struct tty_struct *tty = current->tty;
> >
> > (*tty->driver.write)(tty, 0, str, strlen(str));
> > (*tty->driver.write)(tty, 0, "\015\012", 2);
> > }
>
> And probably oops. Doesn't X disassociate itself from the tty,
> so current->tty could well be NULL. Also, Who's to say that
> "current" is the X server?
>
> Note also that this will write in "text" mode onto a graphics
> mode framebuffer, which won't be very visible.
>

No No. I which people would actually try what was advised before
they responded. This is from X after turning on debugging on a VXI
driver.

Script started on Fri Jul 28 15:20:51 2000
[9;0]# test_vxi
vxi_open
vxi_seek from 0 to 0
SEEK_SET
vxi_read 16384 from 0
Page=0 offset=0 len=4096
Page=1 offset=0 len=4096
Page=2 offset=0 len=4096
Page=3 offset=0 len=4096
vxi_seek from 16384 to 0
SEEK_SET
vxi_write 16384 to 0
1416380 Bytes/Second
vxi_seek from 16384 to 0
SEEK_SET
vxi_read 16384 from 0
Page=0 offset=0 len=4096
Page=1 offset=0 len=4096
Page=2 offset=0 len=4096
Page=3 offset=0 len=4096
vxi_seek from 16384 to 0
SEEK_SET

The 'terminal' is the controlling terminal for the task. The only way
it goes away is if you specifically close 0, 1, and 2. If that's the
case, you are not going to be debugging anyway. Current is always
the task that asked the kernel to do something on its behalf. This
means that you never do any user I/O in an interrupt. That's what you
use printk() for. It's buffered and writes its output to the 'console'
device and to logs that may have been defined.

Any stuff that a user does, open()/close()/read()/write()/ioctl(), handled
by your driver is always performed in the context of the current process.
That's the way Unix and Unix-like Operating Systems work.

Cheers,
Dick Johnson

Penguin : Linux version 2.2.15 on an i686 machine (797.90 BogoMips).

"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro$oft help desk.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jul 31 2000 - 21:00:29 EST