this post was submitted on 14 Feb 2024
567 points (98.3% liked)

Programmer Humor

19623 readers
1 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] bus_factor@lemmy.world 26 points 9 months ago (2 children)

Using a file system is much less bad than dynamically allocating memory, at least as long as you keep a predefined set of files.

[–] troyunrau@lemmy.ca 36 points 9 months ago (2 children)

I hate to alarm you but... What is a file system except dynamically allocated memory. ;)

[–] Redkey@programming.dev 30 points 9 months ago (1 children)

It's a persistent dynamic memory allocation that's accessed by multiple processes! :)

[–] bort@feddit.de 44 points 9 months ago* (last edited 9 months ago) (2 children)
[–] noli@programming.dev 8 points 9 months ago (1 children)

FreeRTOS tasks are basically processes, IIRC other rtoses have similar mechanics too

[–] owenfromcanada@lemmy.world 4 points 9 months ago (1 children)

If you want to get really freaky, try accessing the same flash or RAM from multiple instances of FreeRTOS running on a hypervisor.

[–] noli@programming.dev 3 points 9 months ago (1 children)

Is that just like the shared memory model of parallel computing or are there any added complications? Have you done this before? Please do share your experiences if so cause now I'm interested :p

[–] owenfromcanada@lemmy.world 3 points 9 months ago

It's similar, but the general idea of a hypervisor is to separate resources and avoid this exact situation (it's nuanced and there are some exceptions, but that's the general use case).

The added complication would be that when you compile a binary for one virtual machine, the compiler may optimize things, blissfully unaware that there are other players possibly affecting memory. In a typical multithreaded environment, the compiler has a better picture of how shared resources are being used across threads, but that has to be declared manually for a hypervisor. So if you configure your hypervisor to share resources, you have to be even more vigilant in configuring the individual compilers to play nice.

I don't have a ton of experience with embedded hypervisors, though. And it's worth noting that there are lots of "hypervisors" out there, and some work very differently from others.

[–] frezik@midwest.social 1 points 9 months ago

Lots of microcontrollers have multiple cores now.

[–] sunbeam60@lemmy.one 2 points 9 months ago

And indeed, with memory mapped files the distinction almost disappears completely.

[–] kevincox@lemmy.ml 3 points 9 months ago (1 children)

a predefined set of files

...with predefined sizes located in predefined regions of storage.

[–] bus_factor@lemmy.world 3 points 9 months ago

Yeah, that's what I was implying, just didn't want to write a whole novel about it.