rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
thread_priority.h
Go to the documentation of this file.
1/**
2 * @file thread_priority.h
3 * @brief This file sets the thread priority for the threads running on rusEFI
4 *
5 * @date February 27, 2021
6 * @author Matthew Kennedy, (c) 2021
7 */
8
9#pragma once
10
11// Main loop gets highest priority - it does all the critical
12// non-interrupt work to actually run the engine
13#define PRIO_MAIN_LOOP (NORMALPRIO + 10) //TODO: main_loop should be NORMALPRIO + 10
14
15// TODO: main_loop remove this 2 after migrating to main_loop
16// ADC and ETB get highest priority - not much else actually runs the engine
17#define PRIO_ADC (NORMALPRIO + 10)
18#define PRIO_ETB (NORMALPRIO + 9)
19
20// GPIO chips should be fast and go right back to sleep, plus can be timing sensitive
21#define PRIO_GPIOCHIP (NORMALPRIO + 8)
22
23// TX higher priority than RX because the ECU is generally the one transmitting the highest priority messages
24#define PRIO_CAN_TX (NORMALPRIO + 7)
25#define PRIO_CAN_RX (NORMALPRIO + 6)
26
27// Less critical harware
28#define PRIO_SERVO (NORMALPRIO + 5)
29#define PRIO_STEPPER (NORMALPRIO + 5)
30
31// Logging buffer flush is *slightly* above PRIO_CONSOLE so that we don't starve logging buffers during initialization and console commands
32#define PRIO_TEXT_LOG (NORMALPRIO + 4)
33
34#define TCPIP_THREAD_PRIO (NORMALPRIO + 3)
35#define LWIP_THREAD_PRIORITY (NORMALPRIO + 2)
36
37// Console thread
38#define PRIO_CONSOLE (NORMALPRIO + 1)
39
40#define WIFI_THREAD_PRIORITY (NORMALPRIO)
41
42// Less important things
43#define PRIO_MMC (NORMALPRIO - 1)
44
45// These can get starved without too much adverse effect
46#define PRIO_AUX_SERIAL NORMALPRIO
47#define PRIO_KNOCK_PROCESS (NORMALPRIO - 10)
48#define PRIO_BENCH_TEST (NORMALPRIO - 10)
49
50// These are intentionally low priority so they can't get in the way of anything else
51#define PRIO_STORAGE_MANAGER LOWPRIO + 20
52
53// USB mass storage
54#define MSD_THD_PRIO LOWPRIO + 20
55
56// Lua interpreter must be lowest priority, as the user's code may get stuck in an infinite loop
57#define PRIO_LUA LOWPRIO + 10
58
59// MAX31855 driver
60#define MAX31855_PRIO NORMALPRIO