Task scheulder of two queues
Posted: Tue Nov 26, 2013 8:01 am
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 ?
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 ?