A critical issue for real-time systems is the ability to monitor status of the system with a minimum overhead. Periodically logging to the system logs is one of the possibilities. This is somewhat limited though as the data-volume would become very large and it is often hard to say a-priori what values are going to be relevant for monitoring. Therefore periodic monitoring needs to by adjustable. To make it adjustable a large spectrum of kernel/rt internal values must be reachable with low processing overhead. For this purpose the proc and sysctl interfaces are clearly a most suitable approach. The current /proc file system gives a snap shot of the status of the kernel. But more important for systems that need to exhibit fault-tolerance qualities is the analysis of system tendencies. Roughly this means that the developments of values are more important than the values themselves. With the current concept behind /proc there are two possibilities.
With the limited resources of embedded system the first option more or less is not suitable as it would potentially request log or analysis related processing efforts at the same time that the system is in a high load situation due to error handling. Thus the data needs to be analysed as far as possible at low-load situations. This can be best achieved by delegating the data interpretation to the system's idle task. In order to minimise processing overhead this task is performed in kernel-space and the results are then presented via sysctl or proc.
Here is an example of making RTLinux internal data available by simply dumping the hrtime variable to user-space via /proc/hrtime. This allows user-space applications direct access to RTLinux internal data structures via open/ read/ close on proc files or as shown here make it available in a "`formated"' way to allow use of cat /proc/hrtime to read the RTLinux internal clock.
/* /proc/hrtime "file-descriptor"
*/
struct proc_dir_entry *proc_hrtime;
/* /proc/hrtime read method - just
* dump the dynamic syscall number
* in a human readable manner
*/
int
dump_stuff(char *page, char **start,
off_t off, int count, int *eof,
void *data)
{
int size = 0;
MOD_INC_USE_COUNT;
size+=sprintf(page+size,"RT-Time:%llu\n",
(unsigned long long)gethrtime());
MOD_DEC_USE_COUNT;
return(size);
}
int
init_module(void)
{
/* set up a proc file in /proc */
proc_hrtime=create_proc_entry("hrtime",
S_IFREG | S_IWUSR, &proc_root);
/* assign the read method of
* /proc/hrtime to dump the number
*/
proc_hrtime->read_proc=dump_stuff;
return 0;
}
void
cleanup_module(void)
{
/* remove the proc entry */
remove_proc_entry("hrtime", &proc_root);
}