What I was think was placing a resource semaphore on the console.
So basically, if someone wanted to move the cursor, or print a charecter those routines would do something like a:
Code: Select all
REQUEST_CONSOLE();
Code: Select all
void REQUEST_CONSOLE()
{
while(RESOURCE_CHECK(CONSOLE_ID) == 1);
RESOURCE_SET(CONSOLE_ID);
}
void RELEASE_CONSOLE()
{
RESOURCE_FREE(CONSOLE_ID);
}
void putch(int c)
{
REQUEST_CONSOLE();
.... putch
RELEASE_CONSOLE();
}
void movecursor(int x, int y)
{
REQUEST_CONSOLE();
.... move cursor
RELEASE_CONSOLE();
}
RESOURCE_FREE
RESOURCE_SET
RESOURCE_CHECK
Would all be used to check / modify the state values of various elements. I was thinking I could use an array, and in this case, CONSOLE_ID would be the index in the array. I Could also have KEYBOARD_ID etc etc...
I would have to declared the volitale char RESOURCE[16]; like that right?
This way if the processes are running back and forth, only one of them could actually access the screen resources at a time, and this would save me from having to disable interrupts as an alternative approach.
Is that about right?
Thanks,
Rich