Fix a bunch of multicore race conditions in port functions.

There were numerous race conditions in the port functions. This
was in part due to a bad internal model. System yields now
explicitly hold the lock. Also fix unfairness of scheduler
(scheduler requires that you dump existing process before
 asking for a new one).