ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi all,
I am trying to write a simple kernel module and I have run into an issue which I cannot figure out. So let me give some background on the application.
I have this kernel module which will interact with a nic card. Basically the nic card will have its irq line switched off and software polling will be used. However, when no data is available, my application will enable the IRQ line for the nic card which will in turn call my interrupt handler written in this kernel module.
What I am trying to achieve is the following. Once no data is available, apart from switching on the irq line, the application will wait on a semaphore. On the other hand, when an interrupt is received, the application will be woken up by incrementing the semaphore counter and the irq will never be enable until the data stops coming through.
My problem basically is that I cannot share a semaphore between kernel space and user space. In my kernel module, when I try to create a semaphore with sys_semget(), the module compiles although it gives some warnings, such as *** Warning: "sys_semget" [/home/balinju/repository/workspace/Link/link.ko] undefined!
and insmod fails with Unknown symbol sys_semget.
I would appreciate any help. I am not stuck to using semaphores so if you have any other opinion, please shoot out.
Why not just let your kernel module look for the pid(s) of any user processes running the user-space application, and, when it finds any of them, send the process an interrupt to signal the state change of the kernel process.
Why not just let your kernel module look for the pid(s) of any user processes running the user-space application, and, when it finds any of them, send the process an interrupt to signal the state change of the kernel process.
I am facing the exact same issue as the OP right now and have the exact same problem, though I am working with a DSP rather than a NIC.
Seems to me that taking this route requires the kernel module to implement a policy decision (name of the user process) rather than merely providing a capability (defining an appropriate semaphore). It seems clumsy to me.
Also, I need to process this kdm<->userspace process communication in an interrupt handler, and searching the process table to match names seems rather heavyweight to me in such an environment.
Is this how it is commonly done in Linux when this problem comes up?
Actually, the way to handle my objection about policy and the time penalty of stepping through the process list is pretty straightforward once you think about it.
If the userspace program announces its own pid to the driver when it starts, then the driver doesn't have to search the process list. Multiple userspace programs that want to be notified are easily handled by the driver if it uses a linked list to keep that information.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.