kernel - Fix racing assertion

* Two semaphore assertions could panic the box because they were testing
  conditions subject to SMP races.

* Move the assertions past the lock so they are no longer subject to SMP
  races.

Reported-by: marino