Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added taskYield() after unlocking the mutex, shortend taskname parameter string #11

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ void incTask(void *parameters) {
// Print out new shared variable
// This is different than in the video--print shared_var inside the
// critical section to avoid having it be changed by the other task.
Serial.print(pcTaskGetName(NULL)); Serial.print(" : ");
Serial.println(shared_var);

// Give mutex after critical section
xSemaphoreGive(mutex);
taskYIELD(); // give the other task a chance to run

} else {
// Do something else
Expand Down Expand Up @@ -77,7 +79,7 @@ void setup() {

// Start task 1
xTaskCreatePinnedToCore(incTask,
"Increment Task 1",
"IncTask 1", // Note: max length of taskname parameter is 16 (including '\0')
1024,
NULL,
1,
Expand All @@ -86,7 +88,7 @@ void setup() {

// Start task 2
xTaskCreatePinnedToCore(incTask,
"Increment Task 2",
"IncTask 2", // Note: max length of taskname parameter is 16 (including '\0')
1024,
NULL,
1,
Expand Down