Re: kernel threads

From: Robert Watson (rwatson_at_freebsd.org)
Date: 01/27/04

  • Next message: Matthew N. Dodd: "Re: [PATCH] libusbhid(3) should not clear report_size field"
    Date: Tue, 27 Jan 2004 17:44:22 -0500 (EST)
    To: Renaud Molla Wanadoo <renaud.molla@wanadoo.fr>
    
    

    On Tue, 27 Jan 2004, Renaud Molla Wanadoo wrote:

    > I'm trying to use the kthread library under 5.2-RELEASE but can't
    > compile my program (which actually only tries to create a thread).
    >
    > I've read that there is now KSE to create kernel threads, but i am
    > wondering if it could be used within the kernel code.

    I'm left a little unclear by your message what it is you're trying to do.
    In traditional parlance, a "kernel thread" is a thread executing kernel
    code in the kernel. These are created using the kthread(9) API, which is
    available both to kernel modules and code compiled directly into the
    kernel. You can see examples of kthread use (both compiled in and in
    modules) by grepping in the src/sys/kern and src/sys/dev/* trees. The
    only real caveat here that I know if is that you need to grab the Giant
    lock if your thread will use it, since kthreads don't start holding Giant,
    and that if you call kthread_exit(), you will need to grab Giant before
    that.

    A use of "kernel thread" popularized by linux is the idea of userspace
    threads that are backed by a kernel schedulable thread, as opposed to
    multiple userspace threads being mapped into a single thread making up a
    single process. In FreeBSD 5.x, the "libc_r" library provides multiple
    user threads multiplexed onto a single kernel-visible thread/process.
    "libkse" and "libthr" provide M:N and 1:1 models. By linking your
    application against libkse or libthr and using the pthreads API, you will
    automatically get parallelism and latency improvements over libc_r.

    Hope this helps.

    Robert N M Watson FreeBSD Core Team, TrustedBSD Projects
    robert@fledge.watson.org Senior Research Scientist, McAfee Research

    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: Matthew N. Dodd: "Re: [PATCH] libusbhid(3) should not clear report_size field"

    Relevant Pages

    • Re: Distributions
      ... | general there are a lot of packages for people to use. ... kernel, have to run on a multitude of different systems, they tend to be ... and slower than if you compile those packages, ... can have that stability with virtually any distro. ...
      (Debian-User)
    • Re: Distributions
      ... Ubuntu is based on Debian, ... | general there are a lot of packages for people to use. ... kernel, have to run on a multitude of different systems, they tend to be larger ... and slower than if you compile those packages, ...
      (Debian-User)
    • Problems with custom kernel fbsd 6.2
      ... My kernel for freebsd 6.2 is not compiling but only with my custom config. ... I was able to compile it with the GENERIC kernel included, but my modified one will not compile. ... # Power management support ...
      (freebsd-questions)
    • Re: [PATCH] 2.6 workaround for Athlon/Opteron prefetch errata
      ... >optimisations independently of each other', is fairly simple, (in ... >concept), and elegant, (as it lets you compile the most finely tuned ... >Up to now, selecting a CPU to compile for basically means, "Use ... it's silly to include them all in a kernel for a 386. ...
      (Linux-Kernel)
    • [duke@spacebox.net: oops related crash]
      ... 00000000-0009ffff: System RAM ... 00100000-0020c991: Kernel code ... I just got this while trying to compile pciutils - ... oops through ksymoops and I've attached the output. ...
      (Linux-Kernel)