core: refactor check for valid pid

move into header and remove redundant condition
core: add doxygen header for kernel_types
core/msg: add DEVELHELP checks for valid pid
Merge pull request #1794 from LudwigOrtmann/valid_pid

core: refactor check for valid pid