Hey. Currently my OS is using round robin scheduler (1-way queue). I want to rebuild it and create 2 queues. Let's suppose first queue will have 20ms for each task inside it and tasks inside 2nd queue will get 15ms for executing.
My problem is about displaying graphics at screen. I want to make simple game "snake". I want snake to be moved in 1 direction 1 time for 1 second. When it will be put inside first queue it will be executed too many times and he will move too fast - player will be able to press key arrow fast, and i want make limit 1 press per second.
Lets say i have 4 tasks. 3 tasks in 1st queue in 1 in 2nd queue. Game's task (task1) is inside 1st queue. So until it will be executed next time it's approximately = 20ms (task2) + 20ms (task3) + 15ms (task4) = 55ms
55ms is too often
What are tricks to deal with it ?
I have found 1 simple idea to let move 1 time per second to calculate executions and allow snake to move after calculating 1000ms (1second) / 55ms = 18 ticks.
Is it correct way of doing it or may it be implemented in better sort of way ?
Task scheulder of two queues
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Task scheulder of two queues
I think you're including all the irrelevant things into the problem, making it too difficult so that you're missing the obvious.
How would you solve the problem on a fully functional platform. Like, a game loop in SDL? (or any framework you're familiar with for that matter) It's probably one of the ways to solve it in your own OS, if not the way.
How would you solve the problem on a fully functional platform. Like, a game loop in SDL? (or any framework you're familiar with for that matter) It's probably one of the ways to solve it in your own OS, if not the way.
-
- Posts: 14
- Joined: Tue Nov 26, 2013 7:41 am
Re: Task scheulder of two queues
Combuster wrote:I think you're including all the irrelevant things into the problem, making it too difficult so that you're missing the obvious.
How would you solve the problem on a fully functional platform. Like, a game loop in SDL? (or any framework you're familiar with for that matter) It's probably one of the ways to solve it in your own OS, if not the way.
How ? I have never used SDL ;p
Seems to be simple but i don't see it
Hmm?
Re: Task scheulder of two queues
You should implement some sort of sleep for scheduler so that you don't burn the cpu.
On the game application, you query the time and do rate control, and shouldn't care about how your game is scheduled.
On the game application, you query the time and do rate control, and shouldn't care about how your game is scheduled.