LKML Archive on
help / color / mirror / Atom feed
From: Robert Hancock <>
To: "" <>,
	linux-kernel <>
Subject: Re: list.h , list_head and C++
Date: Tue, 27 Feb 2007 08:34:13 -0600	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <> wrote:
> On Feb 26, 2:26 pm, Robert Hancock <> wrote:
>> wrote:
>>> My C++ program needs an intrusive list, possibly with RCU
>>> capabilities.The data structurelist_head, defined in /usr/include/
>>> linux/list.h , fits perfectly these needs.
>> You really shouldn't use kernel data structures in userspace.
>> The locking and other primitives they depend on are not guaranteed to work.
> The file starts with ' #ifdef KERNEL'  but what hurts me is
> duplicating code.
> Btw:
> - what are the fundamental reasons for not using C++ in the kernel ?

See the archives, this has been discussed before. Aside from some 
developers just not liking C++, the main problem area is that there are 
cases where C++ just does too much behind the programmer's back to be 
practical in a kernel, where things like stack usage are critical. Also, 
a number of C++ features like exceptions would be difficult to support.

> - what prevents the use of RCU lists in user mode ?

Some type of RCU list may be doable, but not with the same code. RCU 
needs to have a way of knowing that all old copies of a data structure 
are no longer in use. In the kernel this is done by checking if all CPUs 
have scheduled since accessing the structure, but that concept doesn't 
really exist in userspace.

Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from
Home Page:

  parent reply	other threads:[~2007-02-27 14:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <>
2007-02-26 14:25 ` list.h , list_head and C++ Robert Hancock
     [not found] ` <>
     [not found]   ` <>
     [not found]     ` <>
2007-02-27 14:34       ` Robert Hancock [this message]
2007-02-27 16:23         ` Avi Kivity
2007-02-27 16:24         ` J.A. Magallón

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).