Page 2 of 2
Posted: Thu May 08, 2008 5:16 pm
by codemastersnake
jal wrote:Woellchen wrote:i just asked how to get the pressed buttons to the right "task" and i think i will do it like 01000101's suggestion by giving each "task" an own char buffer
And now the $100,000 question: where are you going to put that buffer? And who is going to manage it? How does the application extract key presses from it? Thought about locking access to it? Concurrency problems?
JAL
One could really use a circlar queue for that. You can initialize that buffer at a very initial stage of booting. write a getch() function and make it extract a character from the buffer.
And Locking is not that difficult. With lil' hardwork anyone can implement locks to avoid concurrency.
Posted: Thu May 08, 2008 5:31 pm
by Alboin
And don't flame back, because both myself and jal could cook up exactly what you have in less than a day.
I think your knowledge is so limited, you have no chance to succeed making anything even close to an OS.
Whoa, I know you guys are right, but is the excessively rude and elite attitude necessary?
Posted: Fri May 09, 2008 12:58 am
by jal
Alboin wrote:Whoa, I know you guys are right, but is the excessively rude and elite attitude necessary?
Probably not. But even us OS Gods *cough* have a bad day, now and then *cough*.
JAL
P.S.
Please note the sarcasm, I do not consider myself an OS God at all, although JamesM is, of course (being one, not considering himself one, that is).
Posted: Fri May 09, 2008 12:58 am
by jal
Snake wrote:One could really use a circlar queue for that. You can initialize that buffer at a very initial stage of booting. write a getch() function and make it extract a character from the buffer.
Yes, but as soon as you have multiple potential tasks wanting input, you're going to need more than that.
JAL
Posted: Fri May 09, 2008 1:03 am
by White-spirit
You want a getch() function as I see, no ?
You just have to set a global variable with the name last_pressed_key, your keyboard handler puts the char there, and the getch function returns the value of that variable
Posted: Fri May 09, 2008 1:32 am
by JamesM
White-spirit wrote:You want a getch() function as I see, no ?
You just have to set a global variable with the name last_pressed_key, your keyboard handler puts the char there, and the getch function returns the value of that variable
Hi,
That solution is unfortunately not reentrant and will only work for single tasking systems. The OP wanted to be able to dispatch the keys pressed to a particular "task" (although I was and still am confused about how much tasking the OP actually implements).
Unfortunately, that solution also suffers from a rather large problem - what if the user presses *two* keys before the getch() function is called? Where is the other keypress stored?
That is why a circular buffer was suggested.
Cheers,
James