Amiga Threading

Since Amiga processes are so lightweight and use a shared memory model, it has never been a high priority to provide an Amiga-specific threading implementation.

If your software will only be used on AmigaOS then it is fine to launch and control processes using the existing API.

Threading in C and C++

It is very important to note that both C and C++ (current standard) do not specify nor directly support threading. This may come as a surprise to many programmers that have been developing threading applications in both C and C++ for many years.

Since there is no official standard, threading has always been system dependent and several threading standards have come and gone over the years. One popular threading standard is called POSIX Threads or pthreads for short.

AmigaOS supports a subset of the pthreads standard. It is implemented as a standard shared library with both static and dynamic link interfaces. The dynamic link interface is an Amiga shared object named libpthread.so. The static link interface is available in both newlib and clib2 flavours. These link libraries are just thin wrappers for the underlying pthreads.library.

With C the threading issue is relatively simple and GNU GCC supports a memory model which supports threading so there is little for an Amiga programmer to worry about. This is true for all platform GCC supports.

The C++ programming language is a more complicated issue. The current GCC compiler implementation does not support threading on AmigaOS. This can be verified with the g++ -v command. The output of this command will specify what threading model is supported. On AmigaOS it currently states:
Thread model: single

This means threading is not supported. As a consequence, C++ exceptions and the RTTI feature will not function correctly in the presence of threads. Both features are optional in C++ but highly desirable as well. The Amiga programmer needs to make some tough decisions in this case.

Semaphore or Mutex?

Mutexes were introduced into AmigaOS as an alternative in many situations where a Semaphore would be used. A mutex is an opaque type and is much faster especially when the chance of a lock is relatively rare.