simple implementation of cooperative multitasking and round-robin in C