tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

workqueues ....



Hello all,

    I'm trying to work with workqueues and am having a locking problem

    Lets say I have a function f() as follows:

int  f() {
           mutex_enter(&some_mutex);
           ...... code .....
           mutex_exit(&some_mutex);
}

and now lets say that I start another function running via a workqueue, g()
g() {
      ..... some code ....
      if (f()) {
          .... do something else ...
      } else {
          error
      }
}

Now the code that starts the workqueue something like:

         some setup code ....
         workqueue_enqueue(myworkqueue, work_that_runs_g(), NULL);
         some more code
         if (f()) {
              .... success ...
        } else {
            error.
        }

So, my question is:  if g() is running f() and holds the mutex and then the
main code calls f() ... will this be detected as already holding the lock?

If it will be detected as already holding the lock,  how can I do locking
between the code that does the enqueue and the code in the work item?

--Phil


Home | Main Index | Thread Index | Old Index