I wanted to write a few lines on my new event system I implemented to see what you think about it. I just implemented this just now and before venturing any further I could use some opinions.
It works like this. Every syscall will triggers an event. A program in user space can attach listeners to these events containing a callback to one of it's function that it wants to run if this event occurs.
This is what it looks like:
Code: Select all
#include <fudge.h>
void explain()
{
file_write_format(FILE_STDOUT, "You executed a program it seems...\n");
call_detach(0x03);
call_exit();
}
void main(int argc, char *argv[])
{
call_attach(0x03, explain);
call_wait();
}
After wait we are back at the shell again. Now I start another program and just as I press enter the text "You executed..." appears before the normal output of the other program because the callback was triggered. The callback will detach the event and exit but it could just run call_wait() again and keep printing that text before every program I start.
This event system is very basic at the moment and I'll have to think more about what needs to be included.
EDIT: Added an example output for clarity
Code: Select all
fudge:/$ date
Date: 2011-10-31 2:27:41
fudge:/$ event1
fudge:/$ date
You executed a program it seems...
Date: 2011-10-31 2:27:41
fudge:/$