Copyright (c) Hyperion Entertainment and contributors.
PThreads Library
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 the C and C++ standards prior to C11 and C++11 didn't really have support for threading.
Since there was no official standard for so long, threading has 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 full pthreads standard.
Pthreads 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. There is no direct access to the functions in pthreads.library and applications are instead required to use the shared object or static library interfaces in their applications.
threads.library |
---|
There was an older implementation of POSIX threads on AmigaOS called threads.library. This implementation was abandoned and should not be used in any new code. There may still be some old software around which uses threads.library but it will likely not behave correctly. |
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 you will see the following output:
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 multiple threads. Both features are in fact optional in C++ but also highly desirable. Most programs will appear to function correctly most of the time as long as they don't trigger a C++ exception in one thread and try to catch it in another thread. However, when this situation does arise the system is left in an indeterminate state. Anything could happen in the shared memory model which AmigaOS uses.