[Date Prev][Date Next] [Chronological] [Thread] [Top]

[rtl] New Subject: malloc/free -> kmalloc/kfree for ctor/dtor



On Sat, 2 May 1998, Daniele Lugli wrote:

> Ken Teh wrote:
> 
> > On Fri, 1 May 1998, Daniele Lugli wrote:
> >
> > >
> > > No. I have several objects, even if none has a destructor.
> > > (By the way, I tried to add an empty destructor and I got "free undefined").
> > >
> >
> > Isn't this the problem of linking statically with libc?  Kernel drivers
> > don't have the luxury of access to the runtime libraries.  Seems to me that
> > if "free" is undefined, then it's not linked into the object.
> >
> > Just guessing.
> >
> 
> Maybe. But there should be no need for "free" as there is no "malloc" nor "new".
> Why should a destructor need "free" for a global object, no part of which is
> allocated on the heap? Maybe for some internal compiler tables??
> I know of several other situations where _builtin_new _builtin_delete or similar
> suspicious functions are smuggled in even if there should be no need for them,
> but such situations are easily avoidable (eg inlined constructors, virtual void
> functions). I never tried destructors before and I am surprised that they need
> "free".
> I don't know what this "free" is, but if it does memory deallocation it could
> cause problems. Memory allocation/deallocation routines are not reentrant. I
> think that neither kmalloc/kfree should be used in an rt task, as the rt task can
> preempt the kernel.
> 
> Daniele

As I understand new and delete operator, they call malloc and free routine
for memory allocation and after call constructor and destructor.  So if
malloc and free are not reentrant, did kmalloc and kfree are ??
I mean, because rt-task preempt the kernel, did all new and delete should
be call in kernel context and not in rt context ?

Richard

> 
> --- [rtl] ---
> For more information on Real-Time Linux see:
> http://rtlinux.cs.nmt.edu/
> 

<>---------------------------------------------------------------------<>
  Richard Prescott <rip@step.polymtl.ca>
  SAE Robotique  -  Ecole Polytechnique de Montreal

  Pensee du jour :
	echo "\$0&\$0">_;chmod +x _;./_
<>---------------------------------------------------------------------<>


--- [rtl] ---
For more information on Real-Time Linux see:
http://rtlinux.cs.nmt.edu/