Simulated CPU schedule in C++