Linux - KernelThis forum is for all discussion relating to the Linux kernel.
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.
A context-switch takes very little resources, actually. The interrupt can activate a very high priority process, in userland, which gathers information and/or sends it, and there will be very little "latency" involved. This process might, in turn, signal other client processes, also in userland.
@david_8274, "--- if the blocking read is in thread_1, doesn't the user-space program have to first go back to thread_1 before the blocking read gets the interrupt? If the program doesn't do context switching constantly, how does thread_1 gets the interrupt?"
constant cont_switching is not required. when in ISR u invoke wake_up_interruptible(), it will set the TIF NEED_RESCHED flag => on exits from ISR i.e. "rfi", scheduler() would be invoked and context switch could happen.
So your thread_1 will get CPU.
Hope that clarifies...
Last edited by shekharrana; 08-04-2015 at 12:08 PM.
@david_8274, "--- if the blocking read is in thread_1, doesn't the user-space program have to first go back to thread_1 before the blocking read gets the interrupt? If the program doesn't do context switching constantly, how does thread_1 gets the interrupt?"
constant cont_switching is not required. when in ISR u invoke wake_up_interruptible(), it will set the TIF NEED_RESCHED flag => on exits from ISR i.e. "rfi", scheduler() would be invoked and context switch could happen.
So your thread_1 will get CPU.
Hope that clarifies...
@shekharrana
Thank you for the clarification. Then I think this is the way to go -- create a queue and use wait_event_interruptible() and wake_up_interruptible() to catch the event.
@shekharrana
Thank you for the clarification. Then I think this is the way to go -- create a queue and use wait_event_interruptible() and wake_up_interruptible() to catch the event.
I personally think that the best strategy is to go to user-land, and to make sure that the next user-land process to get control of the CPU is the special-purpose one that you want.
Userspace has lots of tools, and are (for the most part) relatively easy to debug. Granted, it does get more complex as you add more parallel activity.
Another common technique is to write a virtual device type, which gives you the "read/write/ioctl" interface that can be used by any userland program. As well as oodles of examples of how to do it, in existing kernel source-code. The whole thing can be bundled as a loadable kernel module.
Last edited by sundialsvcs; 08-05-2015 at 06:48 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.