Skip to content

Instantly share code, notes, and snippets.

@itrobotics
Last active June 7, 2018 16:36
Show Gist options
  • Save itrobotics/7d405ec583317ad4861a to your computer and use it in GitHub Desktop.
Save itrobotics/7d405ec583317ad4861a to your computer and use it in GitHub Desktop.
a simple wait queue example code but it will never wake up.....
/*******************************************************************************
* Copyright (c) 2015 Song Yang @ ittraining
*
* All rights reserved.
* This program is free to use, but the ban on selling behavior.
* Modify the program must keep all the original text description.
*
* 保留所有權利。
* 本程式可任意使用,但是禁止販售行為。
* 修改程式時必須保留所有原有文字說明。
*
* Email: onionys@ittraining.com.tw
* Blog : http://blog.ittraining.com.tw
*******************************************************************************/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/delay.h>
#include<linux/workqueue.h>
#define MY_DEVICE_NAME "my_device"
MODULE_LICENSE("GPL");
MODULE_AUTHOR("ITtraining.com.tw");
MODULE_DESCRIPTION("A Simple Blocking IO device RaspPi");
/* declare a wait queue*/
static wait_queue_head_t my_wait_queue;
/*
* INIT_MODULE -- MODULE START --
* */
int init_module(void)
{
printk("Wait queue example ....\n");
// -- initialize the WAIT QUEUE head
init_waitqueue_head(& my_wait_queue);
printk("MODULE: This moudle is goint to sleep....\n");
interruptible_sleep_on(&my_wait_queue);
printk("MODULE: Wakeup Wakeup I am Waked up........\n");
return 0;
}
/*
* CLEANUP_MODULE -- MODULE END --
* */
void cleanup_module(void)
{
printk("<1> Start to cleanup \n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment