Hello:
I want to add to my OS the stdin/stdout/stderr streams, but I have a doubt about at which level these streams must be open.
I can see two possibilities:
1) At kernel level: In this case all process share the same stdin/stdout/stderr streams.
2) When the process is created: In this case each process have its own stdin/stdout/stderr streams.
I am really lost about this subject, any information to be grateful.
I am looking too for information about how Linux do it (some book or link).
Thank you very much,
pepito
stdin stdout stderr
RE:stdin stdout stderr
I would make it at kernellevel so that every process can use the same stream but i'm really NO expert.
RE:stdin stdout stderr
I would agree, and make a form of abstraction to make it *appear* that each process has its own stdin/out/err... probably through some form of virtual console... these can be directed to the *real* screen via a linux-like ALT-F?, or directed to separated windows ala x11, etc.
--Jeff
--Jeff
RE:stdin stdout stderr
I don't really know what I'm talking about. That said:
If I was writing the virtual console, I would give each virtual console its own buffer of stdin memory. If you run the process in the forground, that process's stdout data is mapped to the vitual console's stdin buffer. Likewise, you can map the stdout to append to a file instead of a virtual console's buffer. For a process running in the background, you would have to have the stdout data get mapped somewhere, possibly a file or a stdin buffer for another process.
Then when the user changes virtual consoles, it can be a matter of telling the video driver (a process running in the background?) to use the data at a different place in memory to draw to the screen. I guess you might say that it is changing the video driver's stdin buffer to point to or read from another virtual console's stdout buffer.
But again, all of this is off the top of my head. I don't really know what Linux or other operating systems do.
If I was writing the virtual console, I would give each virtual console its own buffer of stdin memory. If you run the process in the forground, that process's stdout data is mapped to the vitual console's stdin buffer. Likewise, you can map the stdout to append to a file instead of a virtual console's buffer. For a process running in the background, you would have to have the stdout data get mapped somewhere, possibly a file or a stdin buffer for another process.
Then when the user changes virtual consoles, it can be a matter of telling the video driver (a process running in the background?) to use the data at a different place in memory to draw to the screen. I guess you might say that it is changing the video driver's stdin buffer to point to or read from another virtual console's stdout buffer.
But again, all of this is off the top of my head. I don't really know what Linux or other operating systems do.
RE:stdin stdout stderr
Something I would like to add:
Maybe these stdin and stdout buffers are shared memory since the stdout of one process can be the stdin of another process.
Maybe these stdin and stdout buffers are shared memory since the stdout of one process can be the stdin of another process.