Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    How to wake up a user-space thread from an ISR?

    Hi all,

    Is it possible to do the following in Linux (kernel 2.6.x):

    - A user-space thread goes to "sleep". Using any call/mechanism
    - On a hardware generated interrupt, the Interrupt handler (ISR) "wakes" the sleeping user-thread.

    I have seen wait_event() and wake_up() but it appears that the two should be both user-mode or kernel-mode. Or can they be in different spaces?

    I could use complete, semaphores or queues or anything else but it appears that any kind of such synchronization requires the shared object to be either in kernel-space or user-space.


  2. #2

    Re: How to wake up a user-space thread from an ISR?

    Odd requirement!!

    If you have a thread of execution in user space that does not need to pursue some kind of thread of execution but can just go to sleep while waiting for an event then you would usually just use polling rather than use an interrupt.

    If you have a driver that is waiting on an interrupt which will pass data/event on to a user space application then you would use the sleep_interruptible() call in the driver and wakeup_interruptible() in the ISR of the driver. Usually you make an IOCTL call that you have created and in the driver side you would put the calling user space application to sleep by calling the sleep_interruptible(). Now your application is asleep (which really just means that it's taken out of the scheduler's queue. You receive the interrupt and the driver's ISR calls the wakeup_interruptible() and your application is awake. There are a few versions of the sleep and wakeup routines so you want to have a look at the one that fits your requirements.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts