Re: [Emc-developers] HAL shared memory and the mis-use of hal_malloc

2023-03-26 Thread Sebastian Kuzminsky



On March 26, 2023 5:26:29 PM MDT, andy pugh  wrote:
>It's a tempting thing to do, it keeps the data structures neat, and means
>that you don't have to free on exit, as the whole HAL memory is freed on
>exit.

Non-hal memory (eg from malloc) is also freed when the process exits (it's more 
complicated for kernel mode realtime components, maybe that's what you meant).


>Is using hal_malloc for all your component data bad? Or should we accept it
>for the convenience?

I'd prefer if we used hal memory for things that need to be in hal, and used 
non-hal memory for everything else.

But I don't intend to clean up all the violations of this preference, so my 
opinion doesn't count for much.


-- 
Sebastian Kuzminsky


___
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers


[Emc-developers] HAL shared memory and the mis-use of hal_malloc

2023-03-26 Thread andy pugh
I am working on a HAL driver at the moment, and have started to be
concerned about mis-use(?) of hal_malloc.

Looking at the hostmot2 code the data structures are carefully split into
HAL pins and other data. The HAL pins parts are hal_malloc-ed and the data
parts are rtapi_kmalloc-ed (which is just plain malloc in uspace)

Other components are more lazy, mux_generic for example, and even stepgen.c
hal_malloc the entire data structure.

Possibly this is why we have reports of users running out of hal memory. It
may not be that they have reached the maximum number of pins (which is
rally rather a lot) but that the supporting data has eaten it up.

It's a tempting thing to do, it keeps the data structures neat, and means
that you don't have to free on exit, as the whole HAL memory is freed on
exit.

Is using hal_malloc for all your component data bad? Or should we accept it
for the convenience?

-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is designed
for the especial use of mechanical geniuses, daredevils and lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912

___
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers