-
Notifications
You must be signed in to change notification settings - Fork 0
/
two_core_demo.ino
88 lines (79 loc) · 2.09 KB
/
two_core_demo.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Created by Steven Cybinski
// GitHub: https://github.com/StevenCyb/SecuredLinkedListNode
#include "src/SecuredLinkedList.h"
SecuredLinkedList<int> dataList = SecuredLinkedList<int>();
TaskHandle_t generatorTask;
TaskHandle_t destroyerTask;
void setup() {
Serial.begin(115200);
while(!Serial){}
xTaskCreatePinnedToCore( // Serial task definition on core 0
generatorTaskRoutine, //Task function
"Generator", //Name of task
4000, //Stack size of task
NULL, //Parameter of the task
5, //Priority of task
&generatorTask, //ask handle to keep track of created task
0 //Pin task to core 1
);
xTaskCreatePinnedToCore( // Broker task definition on core 1
destroyerTaskRoutine, //Task function
"Destroyer", //Name of task
4000, //Stack size of task
NULL, //Parameter of the task
5, //Priority of task
&destroyerTask, //ask handle to keep track of created task
1 //Pin task to core 1
);
}
void generatorTaskRoutine( void * pvParameters ){
Serial.println("Generator running on core " + String(xPortGetCoreID()));
while(true) {
if(dataList.size() > 0) {
Serial.println("Pop: " + String(dataList.pop()));
}
delay(10);
yield();
}
}
void destroyerTaskRoutine( void * pvParameters ){
Serial.println("Destroyer running on core " + String(xPortGetCoreID()));
unsigned int counter = 0;
while(true) {
Serial.println("Unshift: " + String(counter));
dataList.unshift(counter);
counter += 1;
delay(10);
yield();
}
}
void loop() {}
// OUTPUT
/*