News for hackers. Stuff that matters.
Re:Real-time Linux is officially part of the kernel by wheels on Thursday September 19, 2024 @08:41PM (#41597736)
There's some difference between user space and kernel. I don't have much experience in the kernel, but I feel like it's more about making sure tasks are preemptable.

In user space it's often about complexity and guarantees: for example, you really try not to do mallocs in a real-time thread in user space, because it's a system call that will only return in an unpredictable amount of time. Better to preallocate buffers or use the stack. Same for opening files, or stuff like that -- you want to avoid variable time syscalls and do them at thread / application setup.

Choice of algorithms needs to be such that for whatever n you're working with, that it can be processed inside of one sample generation interal. I'm mostly familiar with audio -- e.g. if you're generating audio at 44100 Hz, you need your algorithms to be able to process chunks in less than 22 microseconds.

Re:Real-time Linux is officially part of the kernel by saagarjha on Friday September 20, 2024 @03:43AM (#41599731)
Real-time performance is not really possible in userspace unless your kernel is kept in the loop, because preemption can happen at any time.
Re:Real-time Linux is officially part of the kernel by kaba0 on Friday September 20, 2024 @04:42AM (#41600020)
I guess we really have to add whether it is soft or hard realtime we are talking about. The former can be done in userspace (e.g. video games), the latter probably need a custom OS (I don’t think rt-linux is good for actual hard realtime stuff)
Re:Real-time Linux is officially part of the kernel by dgan on Friday September 20, 2024 @04:51AM (#41600064)
How do you handle runtime - defined sizes then? Just preallocate maximum possible number of bytes?
Re:Real-time Linux is officially part of the kernel by wheels on Sunday September 22, 2024 @09:04AM (#41616770)
Well, usually in a realtime system you're required to produce something in a fixed amount of time. Designing the algorithms to not need variable amounts of memory is one of the challenges. Commonly you can have a buffer that's the largest you could reasonably work on in that time slice.