Pios sync primitives

* fixes #1113 
* fixes #1114 
* fixes #1115 
* takes next step in abstracting os api by adding pios_mutex
Yes, you have to look at the code. This one doesn't call lock recursively so it shouldn't be a recursive mutex. Recursive mutexes should cost slightly more than non-recursive ones.