Improve runtime sanity checking and error messages.

Always check the return value of calls to the function sem_init.
This function is not implemented on OS X and always returns an error.

Replace some direct calls to perror in the runtime with calls to MR_perror.
The latter ensures that the error message mentions that the error originates
from a call within the Mercury runtime.

runtime/mercury_context.c
runtime/mercury_prof_time.c:
runtime/mercury_threadscope.c:
	As above.