The function insert returns KERNEL_PID_UNDEF now because pthread_create checks for it.
In pthread_create it checks now if thread_create returns a valid pid
Missing malloc.h and clock_id_t were causing issues to build.
It was tested with this configuration:
- linux ubuntu 14.04.5
- arduino-mega2560 board
- avr-libc-1.8.0-4.1
This change was needed to build iotivity example
Bug: https://github.com/RIOT-OS/RIOT/issues/6241
Change-Id: I82ce246093b3467dfe9746f999bcc9335dbb65f6
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
As discussed in #2725, this commit renames a number of stacksize constants to
better convey their intended usage. In addition, constants for thread priority
are given a `THREAD_` prefix. Changes are:
* KERNEL_CONF_STACKSIZE_PRINTF renamed to THREAD_EXTRA_STACKSIZE_PRINTF
* KERNEL_CONF_STACKSIZE_DEFAULT renamed to THREAD_STACKSIZE_DEFAULT
* KERNEL_CONF_STACKSIZE_IDLE renamed to THREAD_STACKSIZE_IDLE
* KERNEL_CONF_STACKSIZE_MAIN renamed to THREAD_STACKSIZE_MAIN
* Move thread stacksizes from kernel.h to thread.h, since the prefix changed
* PRIORITY_MIN renamed to THREAD_PRIORITY_MIN
* PRIORITY_IDLE renamed to THREAD_PRIORITY_IDLE
* PRIORITY_MAIN renamed to THREAD_PRIORITY_MAIN
* Move thread priorities from kernel.h to thread.h since the prefix has changed
* MINIMUM_STACK_SIZE renamed to THREAD_STACKSIZE_MINIMUM for consistency
Instead of using differing integer types use kernel_pid_t for process
identifier. This type is introduced in a new header file to avoid
circular dependencies.
With `pthread_cleanup_(push|pop)` you can define a function that should
be ran if the thread is exited while it is inside this scope. A thread
can be ended here through an explicit call to `pthread_exit()`, or if
cancellation was requested and a cancellation point was hit.
`pthread_cleanup_*` is mostly only useful together with cancellation
points, and cancellation points are only useful with a cleanup
functionality. Cancellation points are at least partially implemented by
means of `pthread_testcancel()`.
C.f. ["Cancellation Points"][1].
[1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_05_02
This fixes#755.
The pthread ID cannot be reused as soon as the thread ends, because
another thread needs to join it first. `pthread_self()` uses the native
(i.e. RIOT's) thread ID to distinguish itself. A native thread ID can be
reused as soon as the thread ends, since the core knows no join
operation.
In order to not confuse itself with an earlier zombie thread (i.e a dead
non-detached thread, that was not joined, yet), we need to invalidate
the associated native thread ID.
This approach is sane since a dead thread won't call `pthread_self()`
anymore.