//------------------------------------------------------------------- // realtimers.c // // This module creates a pseudo-file (named '/proc/realtimers') // which shows current tasks that have an active 'real_timer'. // // programmer: ALLAN CRUSE // date begun: 19 SEP 2004 //------------------------------------------------------------------- #include // for init_module() #include // for create_proc_read_entry() static char modname[] = "realtimers"; static int my_proc_read( char *buf, char **start, off_t off, int count, int *eof, void *data ) { struct task_struct *tsk = &init_task; struct timer_list *tlp; int len = 0; len += sprintf( buf+len, "\n%s ", modname ); len += sprintf( buf+len, "(jiffies=%d)\n", jiffies ); do { tlp = &tsk->real_timer; if ( tlp->list.next == NULL ) continue; len += sprintf( buf+len, "next=%08X ", tlp->list.next ); len += sprintf( buf+len, "prev=%08X ", tlp->list.prev ); len += sprintf( buf+len, "expires=%-10u ", tlp->expires ); len += sprintf( buf+len, "(pid=%5d): ", tsk->pid ); len += sprintf( buf+len, "%-16s ", tsk->comm ); len += sprintf( buf+len, "\n" ); } while ( ( tsk = tsk->next_task ) != &init_task ); len += sprintf( buf+len, "\n" ); return len; } void cleanup_module( void ) { remove_proc_entry( modname, NULL ); printk( "<1>Removing \'%s\' module\n", modname ); } int init_module( void ) { printk( "<1>\nInstalling \'%s\' module\n", modname ); create_proc_read_entry( modname, 0, NULL, my_proc_read, NULL ); return 0; // SUCCESS; } MODULE_LICENSE("GPL");