#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
int sharedCounter = 0;
SemaphoreHandle_t xMutex;
void task1(void *pvParameters)
{
while (1)
{
int local = sharedCounter;
vTaskDelay(pdMS_TO_TICKS(100));
sharedCounter = local + 1;
printf("Task1 incremento contador a %d\n", sharedCounter);
vTaskDelay(pdMS_TO_TICKS(500));
}
}
void task2(void *pvParameters)
{
while (1)
{
int local = sharedCounter;
vTaskDelay(pdMS_TO_TICKS(100));
sharedCounter = local + 1;
printf("Task2 incremento contador a %d\n", sharedCounter);
vTaskDelay(pdMS_TO_TICKS(700));
}
}
void app_main(void)
{
printf("=== INICIO APP_MAIN ===\n");
xTaskCreate(task1, "Task1", 2048, NULL, 2, NULL);
xTaskCreate(task2, "Task2", 2048, NULL, 2, NULL);
while(1)
{
vTaskDelay(pdMS_TO_TICKS(100));
}
}