LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 09-18-2005, 10:54 PM   #1
sbharsha
LQ Newbie
 
Registered: Sep 2005
Posts: 2

Rep: Reputation: 0
I am trying implement sleep in read system call problem


Hi, all

I am developing the modules on DM320 DSP processor.

I have implemented module for uart, in that implmented interrupt handler for uart port. As as interrupt is recieved from uart port, data from uart port is stored in the simple integer variable .

So my application program which is in user space will continously polling for the any data recived from uart port. on reception of any data the user program will take the next action(mean time at the background another module is running which is playing a video file).

now i will call the read system call from application code . in kernel module i am trying to implement the sleep until i recive the data.

my code for read is below.

static int iuart_read(struct file* filp,char __user* buf, size_t size, loff_t* offset)
{
pRead = remoteCommand;
while(pRead == remoteCommand)
{
if(wait_even_interruptible(uart_wait, (pRead != remoteCommand)))
{
printk(KERN_INFO "Kernl erro " );
return -ERESTARTSYS;
}
}
pRead = remoteCommand;
if(copy_to_user(buf,&pRead,sizeof (int)))
ret -EFAULT;
return ret;
}

my interrupt routine will wake up the sleeping process.
but when i execute the application.

I get the fallowing error

Unable to handle kernel NULL pointer dereference at virtual address 00000004
pgd = c08b8000
[00000004] *pgd=0143a011, *pte=00000000, *ppte=00000000
Internal error: Oops: 807 [#7]
CPU: 0
PC is at $a+0x44/0x74
LR is at 0x60000013


Please can anybody help me to solve this issue..

Thanks in advance.
Harsha S
 
Old 09-19-2005, 12:48 AM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Polling is bad. Calling sleep in a kernel module is really, really bad. Causing a system oops with a null pointer in a kernel driver isn't a good idea, either.

Please consider getting a copy of this book:

http://www.amazon.com/exec/obidos/tg...books&n=507846

The authors discuss in great detail how to design, write and debug a robust kernel driver. They point out a lot of potential pitfalls and "gotcha's" that you'd otherwise have to learn by (hard! unpleasant!) xperience.

And - especially important for your purposes - they have a good section about "asynchronous notification".

'Hope that helps .. PSM
 
  


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
sleep() call prital Programming 2 06-27-2005 08:04 AM
Problem using 'read' system call buckles Programming 6 05-10-2005 12:45 PM
Problem w/ 'read' system call - RH 7.3 buckles Linux - Newbie 3 05-07-2005 01:03 AM
difficulties with large files and system call read/write jwstric2 Programming 2 08-23-2004 12:42 AM
maximum value of count in read system call udayan Programming 2 06-13-2002 07:51 AM


All times are GMT -5. The time now is 08:04 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration