sem: implement sem_timedwait

Exactly the same as sem_wait but with a timer. Luckily, our semaphore
API already have an option to do that. Just use it.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>