LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Re: list.h , list_head and C++
[not found] <1172493644.311389.243780@8g2000cwh.googlegroups.com>
@ 2007-02-26 14:25 ` Robert Hancock
[not found] ` <fa.K8OHlwttPU4TDDzMegRRFAIJrxw@ifi.uio.no>
1 sibling, 0 replies; 4+ messages in thread
From: Robert Hancock @ 2007-02-26 14:25 UTC (permalink / raw)
To: remi.chateauneu, linux-kernel
remi.chateauneu@gmail.com wrote:
> My C++ program needs an intrusive list, possibly with RCU
> capabilities.The data structure list_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.
Also keep in mind that using these structures probably makes your
program a derivative of the kernel and would require your software to be
released under the GPL.
--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: list.h , list_head and C++
[not found] ` <1172571563.228792.208610@h3g2000cwc.googlegroups.com>
@ 2007-02-27 14:34 ` Robert Hancock
2007-02-27 16:23 ` Avi Kivity
2007-02-27 16:24 ` J.A. Magallón
0 siblings, 2 replies; 4+ messages in thread
From: Robert Hancock @ 2007-02-27 14:34 UTC (permalink / raw)
To: remi.chateauneu, linux-kernel
remi.chateauneu@gmail.com wrote:
> On Feb 26, 2:26 pm, Robert Hancock <hanco...@shaw.ca> wrote:
>> remi.chateau...@gmail.com 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 hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: list.h , list_head and C++
2007-02-27 14:34 ` Robert Hancock
@ 2007-02-27 16:23 ` Avi Kivity
2007-02-27 16:24 ` J.A. Magallón
1 sibling, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2007-02-27 16:23 UTC (permalink / raw)
To: remi.chateauneu; +Cc: Robert Hancock, linux-kernel
Robert Hancock wrote:
> remi.chateauneu@gmail.com wrote:
>> On Feb 26, 2:26 pm, Robert Hancock <hanco...@shaw.ca> wrote:
>>> remi.chateau...@gmail.com 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.
>
I believe boost has a C++ intrusive list, which unlike the kernel's is
completely typesafe.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: list.h , list_head and C++
2007-02-27 14:34 ` Robert Hancock
2007-02-27 16:23 ` Avi Kivity
@ 2007-02-27 16:24 ` J.A. Magallón
1 sibling, 0 replies; 4+ messages in thread
From: J.A. Magallón @ 2007-02-27 16:24 UTC (permalink / raw)
To: Robert Hancock; +Cc: remi.chateauneu, linux-kernel
On Tue, 27 Feb 2007 08:34:13 -0600, Robert Hancock <hancockr@shaw.ca> wrote:
> remi.chateauneu@gmail.com wrote:
> > On Feb 26, 2:26 pm, Robert Hancock <hanco...@shaw.ca> wrote:
> >> remi.chateau...@gmail.com 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.
In userspace you're better thinking of a STL list protected by some
POSIX threads primitives. Depending on what you really want to do
with the list, for example a shared work queue, you
could look into condition variables or rwlocks.
Use the standard STL list. You will save a lot of work. And they are not
so bad in performance.
--
J.A. Magallon <jamagallon()ono!com> \ Software is like sex:
\ It's better when it's free
Mandriva Linux release 2007.1 (Cooker) for i586
Linux 2.6.19-jam07 (gcc 4.1.2 20070115 (prerelease) (4.1.2-0.20070115.1mdv2007.1)) #2 SMP PREEMPT
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-02-27 16:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1172493644.311389.243780@8g2000cwh.googlegroups.com>
2007-02-26 14:25 ` list.h , list_head and C++ Robert Hancock
[not found] ` <fa.K8OHlwttPU4TDDzMegRRFAIJrxw@ifi.uio.no>
[not found] ` <fa.9RVekJKqUMy1lb5hfYQYDK8VxnE@ifi.uio.no>
[not found] ` <1172571563.228792.208610@h3g2000cwc.googlegroups.com>
2007-02-27 14:34 ` Robert Hancock
2007-02-27 16:23 ` Avi Kivity
2007-02-27 16:24 ` J.A. Magallón
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).