Add mm_thread_yield() function.
Move memory allocation routines to alloc.c and alloc.h, protect with a spin lock.