printf Call Tree
This page describes what happens when PMON calls printf, or a client
program calls printf via the vector table.
Call Tree
fprintf --\ putchar ------ putc --\
| |
printf --+-- vfprintf --+-- fputs --+-- write
| |
puts --/ fwrite --/
-
printf()
-
printf() calls vfprintf() in order to convert the arguments into a list
of arguments for use by the macros in varargs.h. It also uses this call
to convert the printf(fmt) into fprintf(stdout,fmt).
-
vfprintf()
-
vfprintf() calls the common routine vsprintf() which is used for printf(),
sprintf(), and fprintf(). This routine places the converted string into a
buffer. The buffer is then passed to fputs() for printing.
-
fputs()
-
Since PMON does not implement buffered output, fputs() calls write()
directly.
-
write()
-
write() calls _write(). This indirection is necessary to permit the library
to be used for both building PMON and building clients.
-
_write()
-
Because PMON does not use interrupt driven I/O, it is necessary for
PMON to poll the devices frequently looking for newly arrived
characters. This is done by calling scandevs(). Having done this _write()
then calls _chwrite().
-
scandevs()
-
This function scans all devices looking for newly-arrived input. It
does this by calling the driver with OP_RXRDY. If the return status
indicates that a character is ready, it calls with OP_RX to retreive
that actual character. The characters are placed in the input queue via
Qput(). Characters that need echoing are sent to the device via
_chwrite().
-
_chwrite()
-
This function writes a single character to the designated device. It
does this by repeatedly calling the driver with OP_TXRDY until ready.
It then calls the driver with OP_TX to actually transmit the
character.
Navigation:
Document Home |
Document Contents |
Document Index