Why does my RTOS MicroC project run smoothly outside tasks but fail within tasks?

Please guys @Middleware & OS , why is my RTOS MicroC project encountering issues where functions execute smoothly outside tasks but fails within tasks. Any pointers on troubleshooting this issue? Observe my cod e👇👇👇👇

// Create a semaphore
Semaphore sem = Semaphore(1);

// Task 1
void Task1(void *args)
{
    while (true)
    {
        // Wait for semaphore
        sem.wait();

        // Call function
        adjustTemperature();

        // Release semaphore
        sem.signal();

        // Delay
        delay(50);
    }
}

// Task 2
void Task2(void *args)
{
    while (true)
    {
        // Wait for semaphore
        sem.wait();

        // Call function
        monitorPressure();

        // Release semaphore
        sem.signal();

        // Delay
        delay(50);
    }
}


Any insights or advice on where to begin looking would be greatly appreciated. Thank you in advance!
Was this page helpful?