
          Buffers

Here is a picture of a Java process, its three standard streams,
and their buffers. The "user space" buffers belong to Java classes
and are used by Java methods. For example, the Scanner class, and
all its methods, have a user space input buffer. The PrintWriter
class, and its print(), println(), printf() methods, have a user
space output buffer.


                                    Java process
                       +--------------------------------------+
                       |                                      |
          kernel space | user space                user space |      kernel space
            +------+   |  +------+                  +------+  |       +------+
keyboard -->|      |--->>-|      |->stdin   stdout->|      |->>---+-->|      |---> console window
            +------+   |  +------+                  +------+  |   |   +------+
             buffer    |   buffer                    buffer   |   |    buffer
                       |                                      |   |
                       |                           user space |   |
                       |                            +------+  |   |
                       |                    stderr->|      |->>---+
                       |                            +------+  |
                       |                              buffer  |
                       +--------------------------------------+


This picture can help explain almost everything that seems odd about
the programs in this folder.

If stdout and stderr and not connected to the same output device,
then each stream will have a kernel space buffer between its user
space buffer and its output device.

Note: C and C++ processes do not have a user space buffer for stderr.
