Virtual time!?

Jan 31, 2016 at 8:10am
Hi guys, so I'm having this exercise in Stroustrup's book and I think its by far the most interesting one! You can check it out if you want - chapter 20, exercise 11.
Here's some part of it
...There should be a scheduler implementing a concept
of virtual time. Provide a function task::delay(long) that ‘‘consumes’’ virtual time....

I was looking at this virtual time thing but couldn't find much about it but in the meantime I found such interesting stuff as windows.h and there this Sleep(mseconds) function is available.
It would create a delay but its not really a "virtual time".

How do you guys think Stroustrup meant this virtual time to be implemented?
Last edited on Jan 31, 2016 at 8:11am
Jan 31, 2016 at 12:02pm
If he has not explained sleeping, timers or anything like that I think he might just mean you should simulate time. Maybe the delay function should not actually wait but just advance the clock so that when the function returns the "virtual time" has advanced x ticks.
Last edited on Jan 31, 2016 at 12:02pm
Jan 31, 2016 at 10:33pm
Tnx for reply man! I don't think timers will actually be explained and sleep as well. So as far as I understood you're suggesting that my "virtual time" would be like variable int x that I would increment (or maybe in this case when I'm "consuming" it - decrement) lets say after each function call? It would take away all the fun for sure :D
Last edited on Jan 31, 2016 at 10:36pm
Feb 1, 2016 at 7:56am
Yeah, that's my guess, but I don't have the book so I'm just basing this off the short snippet you posted here.
Last edited on Feb 1, 2016 at 7:57am
Feb 1, 2016 at 8:51am
Ok tnx you man!:)
Topic archived. No new replies allowed.