#linuxcnc-devel Logs
Dec 12 2020
#linuxcnc-devel Calendar
02:22 AM mentyl: Hi, I'm new here and I have one question. Is share memory (Ring Buffer) between Hal in RT and Hal in User mode available and safe?
03:15 AM rs[m]: mentyl: there is a shared memory region in hal. not sure what you mean with "safe". if you structure your development as a hal component and communicate vial hal pins you should be OK.
03:20 AM mentyl: I want to put in to buffer in on Hal RT and get from it in other Hal User
03:29 AM rs[m]: I'm not completely sure how consistency between non-rt and rt-part is achieved, as you can't really have any locks I guess you will need to use lock-free data structures that can be manipulated "atomically"
03:36 AM mentyl: I think no lock is required In ring buffer bot hall will not change same values i use this method in microcontroller word and if start,end are single word with single change operaton this working fine
03:37 AM mentyl: But i don't see structure to share memory like hal pins
03:38 AM rs[m]: mentyl: you have to be somewhat careful with memory ordering, esp. if this should also run on ARM architecture
03:39 AM mentyl: 32bit and up will be ok for me
03:40 AM rs[m]: mentyl: look at linuxcnc/src/hal/hal.h
03:40 AM rs[m]: hal_malloc will get you a chunk of shared memory
03:41 AM mentyl: in hal.h i see hal_port_shm_t structure but without any example
03:43 AM rs[m]: with careful i mean things like writing data and then incrementing a pointer which may under circumstances be reordered by hardware which could lead to hard to track down races
03:44 AM rs[m]: /** hal_malloc() allocates a block of memory from the main HAL
03:44 AM rs[m]: shared memory area.
03:44 AM rs[m]: ...
03:45 AM mentyl: ok I must test using hal_malloc()
03:46 AM mentyl: Thanks for help :)
03:46 AM rs[m]: yw
03:47 AM mentyl: I plan to use it for USB IO I test it using Hal User but I want to do it litte faster using part in Hal RT :)
06:16 AM andypugh: mentyl: I don’t think it is a ring buffer. HAL uses a flat area of shared memory. (In effect HAL pins are variables inside separate blocks of running code that point to the same memory)
06:17 AM andypugh: You have a choice of using the existing HAL memory for your components, or creating a private one for the realtime and userpace parts of your own component.
06:17 AM andypugh: hal_port is pretty new. So new that I haven’t even looked at it, so can’t really help.
01:08 PM rs[m]: andypugh: it should be possible to allocate a ring-buffer in hal shared memory
01:08 PM rs[m]: s/it should be/you could/
01:08 PM andypugh: Yes, but you would have to handle it yourself, it’s not automatically a ring buffer.
01:09 PM rs[m]: of course
04:06 PM -!- #linuxcnc-devel mode set to +v by ChanServ
10:36 PM skunkworks: just used stepconf to create a stepper config. with limit swiches. i ran the config and hit home. z started homing. i hit the escape button and y started homing.
10:37 PM skunkworks: will play some more