LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-17-2005, 10:32 AM   #1
okeyla
Member
 
Registered: Nov 2004
Posts: 47

Rep: Reputation: 15
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);	
}
 
Old 05-17-2005, 02:50 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
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?
 
Old 05-17-2005, 09:15 PM   #3
okeyla
Member
 
Registered: Nov 2004
Posts: 47

Original Poster
Rep: Reputation: 15
So is there any other way to do this?
Trigger a timer in device driver...
>_<
 
Old 05-18-2005, 07:41 AM   #4
mehuljv
Member
 
Registered: Nov 2004
Posts: 72

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

Bye
Mehul
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
writing printer device driver in linux sidbash Programming 3 07-04-2004 11:16 PM
Need help in writing device driver eshwar_ind Programming 1 02-07-2004 03:46 PM
Quick and easy solution for writing a linux device driver? mr_segfault Programming 5 01-08-2004 10:45 PM
Device Driver Writing Red Hat 8 & 9 unicorn21 Red Hat 2 12-14-2003 03:01 AM
writing a config file for a device driver britneykiller Programming 0 03-08-2002 08:22 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration