# include < linux/ module. h>
# include < linux/ init. h>
# include < linux/ workqueue. h>
static struct workqueue_struct * queue = NULL ;
static struct work_struct work;
static void work_callback( struct work_struct * data)
{
printk( KERN_ALERT "work callback function./n" ) ;
}
static int __init test_init( void )
{
queue = create_singlethread_workqueue( "helloworld" ) ;
if ( ! queue )
goto err;
INIT_WORK( & work, work_callback) ;
queue_work( queue , & work) ;
return 0;
err:
return - 1;
}
static void __exit test_exit( void )
{
destroy_workqueue( queue ) ;
}
MODULE_LICENSE( "GPL" ) ;
module_init( test_init) ;
module_exit( test_exit) ;
11-15
11-15
11-15
11-15