ozgur
ozgur

Reputation: 2719

Is Posix threads available on embedded Linux platform?

Sometimes I read about (if I'm not interpreting wrong) that posix threads are not available or valid on sone platforms such as some RTOSs which inplements their own threading mechanism.

So, is posix thread can be considered as standard (at least on general purpose OS)? And is it platform independent?

Upvotes: 3

Views: 542

Answers (2)

πάντα ῥεῖ
πάντα ῥεῖ

Reputation: 1

"So, is posix thread can be considered as standard (at least on general purpose OS)?"

No, it's not standard for OS's that POSIX threads are supported.

I'd say that std::thread implementations rely on some POSIX thread commonly defined features.

Embedded Linux platforms are POSIX compatible of course, and you can rely on pthreads.

Windows platforms (counting as a general purpose OS) for instance, doesn't support POSIX threads natively, but there are wrapper APIs available with e.g. MinGW or cygwin.

"that posix threads are not available or valid on sone platforms such as some RTOSs which inplements their own threading mechanism."

Other embedded platforms like FreeRTOS don't support that threading model directly, but are eligible to write a POSIX wrapper.

The basic thread semantics could be usually wrapped well for the POSIX standard requirements, and injected to newlib or whatever you like to use as binding for realising the standards implementation.

Upvotes: 4

user4581301
user4581301

Reputation: 33932

POSIX, the standard that specifies pthread, is a standard (Actually, more a group of standards) defining operating system behavior and functions. An OS either implements the standard or it doesn't. The goal of POSIX is platform independence, all the same OS calls on all platforms, but as with all standards, folks bolts stuff onto the edges to get extra functionality that is not portable or leave stuff out when it becomes problematic.

Linux implements POSIX fairly closely (but not even all families of Linux agree on how closely) so your concern will be with compatibility edge cases that I hope will be well documented at this point.

Windows POSIX support is somewhere below weak so you cannot count on it on general purpose OSes.

I recommend a quick search here on SO, Google or giving Wikipedia a look-over for a better description of POSIX.

Upvotes: 3

Related Questions