RTOS basics

I am currently working with a firmware system that has three tasks of equal priority (P2), scheduled a 1 ms time slice. Majority of the MCU interrupts (TM4C1290NCPDT) have equal priority (P1). The I2C module is P0, one periodic timer is P2. What happens when a task is running, but receives a general purpose MCU interrupt from another task? How does the RTOS scheduler handle this?

One of the ISRs in the system is overloaded, with interrupts that happen inside it. I am trying to create a context switch to a dedicated task (same priority P2) to relieve the ISR using xSemaphoreGiveFromISR in addition to
if (higherPriorityPrinterTaskWoken == pdTRUE )
portYIELD_FROM_ISR(higherPriorityPrinterTaskWoken);
This task is being called.

void PrinterTask(void * pvParameters)
{

for(;;){
    UARTprintf("\nIn Printer task");
   if (xSemaphoreTake(xPrinterSemaphore, portMAX_DELAY) == pdTRUE){


       PRINTHEAD_CountAndPrint();

       xSemaphoreGive(xPrinterSemaphore);
   }
}

}

  1. I want this dedicated task to only be called when the ISR determines a context switch, not otherwise.
  2. When this dedicated task finishes its processing, I want the control to return to the originating task. And for the scheduler to resume as before, time splicing the 3 original tasks.
  3. I tried making this dedicated task a higher priority. In this case, this appears to be the only task the scheduler allows to run.

I am trying to understand how to setup the RTOS for this purpose.
Thanks,
Priya

Since your task gives the Semaphore in the loop, it will of course be ready to take when you come around to taking it. If this Semaphore is supposed to be the signal from the ISR to the task, then the ISR should give and the task just take, then it will only run when the ISR signals it.

As an aside, using the direct-to-task notification would be simpler and lighter weight.

I am currently working with a firmware system that has three tasks of equal priority (P2), scheduled a 1 ms time slice. Majority of the MCU interrupts (TM4C1290NCPDT) have equal priority (P1). The I2C module is P0, one periodic timer is P2. What happens when
a task is running, but receives a general purpose MCU interrupt from another task? How does the RTOS scheduler handle this?

Sorry but I’m not following the above - maybe because you have a misunderstanding between the difference between task priorities and interrupt priorities?
Are you familiar with how interrupts operate? This link is over complex for your needs but is still useful:
https://en.wikipedia.org/wiki/Interrupt

So interrupts are a hardware feature, the priorities assigned to interrupts are defined
by the hardware, and [assuming interrupts are enabled] an interrupt service routine will always execute in response to an interrupt no matter what the processor is executing when the interrupt occurs. FreeRTOS on the other hand is a software library that implements multithreading. The priorities assigned to FreeRTOS tasks are defined by the software and are completely unrelated to interrupt priorities. The lowest priority hardware interrupt will always interrupt even the highest priority FreeRTOS task.

One of the ISRs in the system is overloaded, with interrupts that happen inside it. I am trying to create a context switch to a dedicated task (same priority P2) to relieve the ISR using xSemaphoreGiveFromISR in addition to

for(;;){

    UARTprintf("\nIn Printer task");

   if (xSemaphoreTake(xPrinterSemaphore, portMAX_DELAY) == pdTRUE){

       PRINTHEAD_CountAndPrint();

       xSemaphoreGive(xPrinterSemaphore);

   }

If you are always unblocking the same task then a direct to task notification will be much more efficient than a semaphore.
https://www.freertos.org/RTOS-task-notifications.html