LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Writing Device Driver... (https://www.linuxquestions.org/questions/programming-9/writing-device-driver-324385/)

okeyla 05-17-2005 10:32 AM

Writing Device Driver...
 
When "open" the device , a timer will be triggered.
"Ioctl" could read the timer present value.

I could compile this device driver module successfully,
but when doing insmod , linux cannot recognize
"setitimer" and "signal" these 2 kernel functions.
What should i do?

Code:

#include <linux/types.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/timer.h>
#include <linux/sched.h>
#include <linux/fs.h>
#include <linux/wait.h>
#include <asm/irq.h>
#include <linux/errno.h>
#include <linux/ioctl.h>
#include <asm/uaccess.h>
#include <asm/semaphore.h>

static int MyDevice_open(struct inode *inode, struct file *filp)
{
        struct timeval my_value={1,0};
        struct timeval my_interval={1,0};
        struct itimerval my_timer={my_interval,my_value};
        setitimer(ITIMER_REAL, &my_timer, 0);
        signal(SIGALRM, (sighandler_t) foo);       
}


Mara 05-17-2005 02:50 PM

Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.

I'm not sure, but are you sure you can use setitimer and signal in kernel mode?

okeyla 05-17-2005 09:15 PM

So is there any other way to do this?
Trigger a timer in device driver...
>_<

mehuljv 05-18-2005 07:41 AM

hi,
u can use kernel_times. Read device driver By rubini and corbet. chapter no. 6 in 2nd edition.

Bye
Mehul


All times are GMT -5. The time now is 01:22 AM.