How’s this for an off-the-wall product idea.
A universal control panel for software. What it does is it allows
you to modify variables through a controlled-access resource manager
in running programs.
Why? I’ve often had some kind of 24x7 server running and decided,
“ah crap, I need to turn on debugging for a while”. I really hate
the thought of having to restart the server with the -D flag, run
it for a bit, and then restart it again with out the -D flag.
So, here’s a set of API’s that I’m proposing to fix this.
In your server’s main(), you’d put something like:
main ()
{
// initialize your normal stuff here
control_panel_register (“servername”);
control_panel_register_variable (&debug_flag, “Debug Flag”);
// proceed with server stuff and the rest of your code
}
Then, from a command line or GUI, the “universal control panel” would
simply open “/dev/controlpanel/servername”, and get a list of variables
that are controllable. In this example, it would just come up with
a text string that sez “Debug Flag” and some id number.
From the universal control panel, I could then turn on the debug flag,
turn it off, examine it, etc.
There are a few details here that are of interest as well.
- why not have every server do it its own way? (I think that question
just answered itself) - how do we control access between the implicit resmgr thread and the
regular server threads to the variables?
Well, I thought about that, and there are a number of clever solutions:
a) we don’t. If we “cripple” this idea to just accessing single
char variables, there’s no issue with atomic operations.
Even if we don’t limit it to just char variables, we can still
do a “good enough” approach even without atomic operations.
Certain operations can be coded to be non-atomic tolerant.
b) we implement a set of macros that do mutex operations on the
controlled variables, effectively providing a read/write
interface. I don’t like the idea of anyone explicitly having
to worry about the mutex functions, because that just leads to
trouble, and makes this idea a lot more intrusive to the code
to implement. I like the idea of just coding up the usual
“if (debug_flag) { … }” kind of stuff. - for variables that come in and out of scope, there could be an
“unregister” call as well, which would effectively remove that address
from the control of the resmgr thread. - why can’t we do this with GDB or the /proc filesystem? You could do some
of it, but certainly not the synchronizational aspects.
The true beauty in this scheme lies in the fact that I have one year to
patent it! Er, I mean, the true beauty in this scheme lies in the fact
that it’s not intrusive to the code; just a few lines up front in the
code. The control_panel_*() functions could even look at an environment
variable to allow them to “opt-out” in case of limited sizes on embedded
systems. And, it’s not just for servers – it can be quite useful for
long-running tasks that aren’t servers.
Thoughts?
Cheers,
-RK
–
Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.