
Show HN: A thread hierarchy management library in C - gradschool
https://github.com/gueststar/nthm
======
mancini0
Stupid question because I am very new to embedded programming and C (I started
my journey this weekend), but could one use freertos's tasks library in a
regular x86 desktop application to accomplish something similar?

~~~
anitil
Not stupid at all. Like many early questions in programming, it's actually a
fairly deep.

Because FreeRTOS is unlikely to play nice with your host OS, typically you'd
need to emulate a target (say, arm) using an emulator like qemu. Once you're
at that point, you could run it like any other program. There's probably more
complexity to it like building an image but there'd be a bunch of tutorials
for this.

When would you typically do this? For testing your FreeRTOS (or other bare
metal) code without actually loading it on to your device and power cycling
it. Maybe as part of a regression test

------
iTokio
It reminds me of
[https://github.com/sustrik/libdill](https://github.com/sustrik/libdill)

~~~
rurban
Me not. Dill is to call coros with a native C ABI, whilst this is to
orchestrate native threads, calls into the threads are setup via pipes, not
function calls.

both are doing the most natural thing for proper concurrency. nthm with true
concurrency (native threads). dill with fake concurrency, coros only, aka
green threads.

------
Koshkin
And for those of us who write C++ there's always Intel's Threading Building
Blocks. (Not sure if any other language has something equal in power and
convenience.)

~~~
dman
Would openmp fit in with how you use TBB? In the past I have used them to
solve similar problems.

~~~
Koshkin
TBB is based on the use of nested threads. We rely on much of what TBB has to
offer, which includes concurrent containers and flowgraphs. Here's a nice
overview by Mike Voss of what makes TBB different from OpenMP and C++ standard
threading:
[https://software.intel.com/content/www/us/en/develop/article...](https://software.intel.com/content/www/us/en/develop/articles/intel-
threading-building-blocks-openmp-or-native-threads.html).

