hal_create_thread(3hal)
β¨ hal_create_thread β HAL manual, section 3hal β¨
okay bestie, buckle up, we're doing realtime threads today and it's lowkey iconic π§΅π
πΈ NAME πΈ
hal_create_thread β spin up a HAL thread, bestie. that's the whole job. creating threads, that's her π
π SYNTAX π
int hal_create_thread(const char *name, unsigned long period, int
uses_fp)
int hal_thread_delete(const char *name)
π¦ ARGUMENTS π¦
nameβ the name of the thread. yeah. that's it. name your baby πΌperiodβ the interval, in nanoseconds, between iterations of the thread. nanoseconds bestie. we are NOT playing around with milliseconds here πuses_fpβ must be nonzero if a function that uses floating-point is gonna get attached to this thread. nonzero. zero is not it. fr fr. if you're doing float math and you pass zero here, that's on you π
π DESCRIPTION π
so hal_create_thread establishes a realtime thread, and that thread will execute one or more HAL functions periodically. like a little hamster on a wheel, except the wheel is a hardware timer and the hamster is deterministic πΉβ¨
here's the tea though, and you need to hear it:
- All thread periods are rounded to integer multiples of the hardware timer period. no in-between values, it snaps. periodt.
- The timer period is based on the first thread created. so whoever goes first sets the vibe for everybody. main character energy, honestly π
- Threads must be created in order, from the fastest to the slowest. fastest first, slowest last. do not freestyle this.
- HAL assigns decreasing priorities to threads that are created later, so creating them from fastest to slowest results in rate monotonic priority scheduling. that's the whole point, that's the slay. fastest thread gets the highest priority, and it just cascades down from there. chef's kiss π€
and then hal_delete_thread deletes a previously created thread. bye bestie, you served π«Ά
not me pointing out that the description sayshal_delete_threadwhile the SYNOPSIS listshal_thread_deleteβ I'm just telling you what the page says, I don't make the rules π
π₯ REALTIME CONSIDERATIONS π₯
call only from realtime init code. NOT from other realtime code. NOT from non-realtime code. just init code. that's the only door, babe πͺβ¨
π RETURN VALUE π
returns a HAL status code. classic. π
β SEE ALSO β
hal_export_funct(3hal)β go read it, bestie, they're besties π«Ά
okay so that's the whole page, no cap. this one came from the LinuxCNC Documentation, dated 2006-10-12, and it lives in the HAL manual as hal_create_thread(3hal). she's been iconic since '06 and she's still iconic now πβ¨π
π¦ where this page comes from
- debian trixie: linuxcnc-uspace-dev 1:2.9.4-2+deb13u1 Β· GFDL-1.1-or-later
- ubuntu questing: linuxcnc-uspace-dev 1:2.9.4-2ubuntu2
- ubuntu resolute: linuxcnc-uspace-dev 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- ubuntu stonking: linuxcnc-uspace-dev 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms