adding dispatch/context switch
added ctx switching and dispatch funcs
resolved merge conflict