How does process system work?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Ben Hsu

How does process system work?

Post by Ben Hsu »

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?

Thanks.
Chase

RE:How does process system work?

Post by Chase »

Except in as single tasking OS a process is not directly
resonsible for things like reading from the keyboard.
The typically model as I understand it is that when a keyboard interrupt
occurs the OS switches to the keyboard handler and saves the keystrokes.
What makes everything work out ok is that in addition to saving the keystrokes
the OS also saves information about what application was currently selected
in the forground). Then it's possible that when a process in a certain
application calls an OS service to read from the keyboard, then the OS figures
out what keystrokes to report back to the process.

Is that kind of what you where asking?
Alexei A. Frounze

RE:Howšdoesšprocessšsystemšwork?

Post by Alexei A. Frounze »

>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.
Alexei A. Frounze

RE:Howšdoesšprocessšsystemšwork?

Post by Alexei A. Frounze »

>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.
Post Reply