Synchronizing kernel threads

Two questions:

    Requires Free Membership to View

  • One: How do you achieve synchronization between kernel threads that access common structure(s)?

  • Two: Can we assign a kernel thread to run on a selected processor on SMP machines?

  • Whoa, kernel programming questions. I haven't spent much time hacking threads in the kernel source, so I'm not the right expert. My understanding is that even the 2.6 kernel does not support genuine real-time scheduling yet. Real time scheduling allows a single thread to grip onto a CPU and not be interrupted, ever. So the answer to your second question is NO if you're trying to grip a CPU permanently. Of course, since you have the source, anything is in theory possible -- it might be too much effort to justify, though.

    To synchronise two kernel threads, just use any synchronisation technique, like a semaphore and/or signal. A crude solution if one of your threads is time-dependant and you have multiple CPUs is to use a spinlock to keep one thread busy until circumstances change. That solution is bad for user-level performance, though.

    This was first published in May 2004

    Join the conversationComment

    Share
    Comments

      Results

      Contribute to the conversation

      All fields are required. Comments will appear at the bottom of the article.