Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 09-18-2005, 09:54 PM   #1
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 " );
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-18-2005, 11:48 PM   #2
LQ 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:

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


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

All times are GMT -5. The time now is 07:36 AM.

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