LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-05-2011, 05:56 AM   #1
haribabu1836
LQ Newbie
 
Registered: Apr 2010
Posts: 16

Rep: Reputation: 0
How to solve this scenario in Linux device drivers


Hi All,

I have a scenario listing below, Please let me know how can i achieve this in linux.

If application program is trying to read data in a device/driver but data is not present at that moment, application should go into sleep/block state. Data came into device later and at this point of time how device/driver can tell to application or wakeup the application that now data is ready for read.

Please help me which mechanism will suitable to solve this in Linux, Thanks.
 
Old 12-05-2011, 06:38 AM   #2
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
In the default case (no special open-time flags), the 'read' handler in your userspace driver should block (make the userspace thread sleep until data is available). If the userspace application has specified the O_ASYNC open()/fcntl() flag, raise a signal. If the userspace application has specified the O_NONBLOCK open()/fnctl() flag, return EWOULDBLOCK instead.

For examples, see the Linux Kernel Module Programming Guide, Blocking Processes section. There is even an example character driver in the guide.

For detailed examples on character devices, blocking and signaling, see chapters 4, 5 and 6 in Linux Device Drivers, 3rd edition.
 
1 members found this post helpful.
Old 12-09-2011, 01:22 AM   #3
haribabu1836
LQ Newbie
 
Registered: Apr 2010
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Nominal Animal View Post
In the default case (no special open-time flags), the 'read' handler in your userspace driver should block (make the userspace thread sleep until data is available). If the userspace application has specified the O_ASYNC open()/fcntl() flag, raise a signal. If the userspace application has specified the O_NONBLOCK open()/fnctl() flag, return EWOULDBLOCK instead.

For examples, see the Linux Kernel Module Programming Guide, Blocking Processes section. There is even an example character driver in the guide.

For detailed examples on character devices, blocking and signaling, see chapters 4, 5 and 6 in Linux Device Drivers, 3rd edition.

Thanks Nominal.
 
  


Reply

Tags
devicedrivers, linux



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
linux device drivers : how can i unregister a character device ? zampa Linux - General 5 06-21-2012 05:34 AM
[SOLVED] Authetication is required to mount the device solve plz deb1bhu Linux - Newbie 4 06-21-2010 04:21 PM
Linux Device Drivers isalmbio Linux - Hardware 4 12-16-2006 11:33 AM
Why doesn't Linux support UPnP to solve its device driver problems? john_walsh54 Linux - Hardware 2 05-31-2004 09:16 PM
linux device drivers alaios Programming 1 05-24-2003 08:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:03 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