>On 2001-05-21 11:17:22, Ben Hsu wrote:
>Hello people,
> Anyone know how does the process system should work?
>My problem is with the concept that if the CPU is
>keep on switching back and forth b/t several processes
>, if the user is using say process C and whie the
>user is typing in something the CPU switched off
>to another process say D, what happens to the user
>then? Is the process model saying that any data
>intercepted are stored in the stack later poped back
>out as the user program (process C in this case)
>is using the CPU again? Or is it just simply that
>all other processes have to wait until an user process
>is done? Or is my concept entirely wrong?
There is only one program which allows user input,
e.g. a program that holds input focus. You don't
have 2 keyboards or 2 users, do you?
So one of the processes holds the focus and
input from the keyboard and mouse (if the pointer
is inside the program's window or the program
occupies the entire screen) and everything goes
to this process.
Now, there's also only one process that is
currently executed by the OS and CPU. And this one
doesn't have to be the same focused process, they
can be different ones.
You may wonder how would you get anything in the
focused program if it's not the current one, right?
But it's not a problem. Pressed buttons and
mouse movements generate IRQs that are handled
right away and the OS may either copy this info to
the focused process or put it into a buffer and
finish everything later, when focused becomes
current.