Pios sync primitives

* fixes #1113 
* fixes #1114 
* fixes #1115 
* takes next step in abstracting os api by adding pios_mutex
Ditto 0xffff constant