Ask the Expert

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

    There are Comments. Add yours.

     
    TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

    REGISTER or login:

    Forgot Password?
    By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
    Sort by: OldestNewest

    Forgot Password?

    No problem! Submit your e-mail address below. We'll send you an email containing your password.

    Your password has been sent to: