-1

I have a project (a 2-player game) made in FreeRTOS. The game has 3 tasks (Game Render, Joystick Task and a PC Serial Communication).

Shared resources include:

  • Player 1 and Player 2 locations/coordinates. They are manipulated by Serial and Joystick task respectively. The game render reads both of these locations and displays them. (Player 1 location is shared with Game Render and Player 2 with Game Render).
  • A queue that is shared between the game render and the serial task (sending data and getting acks); the queue has been protected with a mutex on all write operations.

My question is which of these 2 scheduling is more suitable for this project: Rate Monotonic or Deadline Monotonic?

The tasks are not independent in a way that the serial communication uses acks? I think it should be Deadline Monotonic but not entirely sure?

  • Duplicate of https://electronics.stackexchange.com/questions/450593/what-scheduling-should-i-choose-for-my-program-on-a-freertos-system **cross posting is not permitted** – Chris Stratton Jul 31 '19 at 06:30
  • While you *could* do this with an RTOS, it's actually much simpler to just write it as a main program loop which takes any input, then updates positions, then redraws the screen. – Chris Stratton Jul 31 '19 at 06:33

1 Answers1

0

To choose between DMS and RMS you need to know periods and deadlines for each task. From my experience it is better to focus on good overall design first and then measure and tweak the priorities to achieve best response times.

On of best summaries of good design principles I've encountered is this. In your case I would represent the two players as 'active objects' with own input event queues. Send event to the players from serial task, or even directly from ISR. The game render would then also be an AO receiving events from players, or a mutex-protected resource - it depends on what the render output is (how long does it take mostly). Serial input and serial output should be considered two separate things - in most cases it doesn't make sense to conflate the two.

Here is another link that might be useful - look at '1.4 The Design of the “Fly ‘n’ Shoot” Game'

Also, you don't need a mutex lock for xQueueSend and for sending from ISR you only need to use xQueueSendFromISR.

mariusz-r
  • 56
  • 3