Semaphore support

Thread updates for termination/yield.
Added semaphore support.
Split scheduler from kernel code and moved the scheduling related
functions from threads to the scheduler.
Minor updates to the rest for documentation purposes.