Multitasking not working properly

Hello forum people,

In my Project I have created two different tasks in which both tasks having a dedicated UART’s and using the main microcontroller as ESP32 Wemos D1 R32, But The issue I am facing while I execute is , For the first time everything going as expected but after one complete cycle for the second time the task one is executing only halfway only and it immediately jumps to second task execution which is not required process and I have given same priority to both the task

After some reading on, I got to understand that as both the tasks are given same priority context switching is happening which is very fast , so to avoid that I changed configUSE_TIME_SLICING macro to “0” , But still no change in the code
Can anyone here explain me how to solve this issue its very urgent

Are you blocking or explicitly yielding somewhere in the task which is causing context switch? Can you share definitions of your tasks? Also, can you check raising one task’s priority and adding a delay after one iteration so that the other lower priority task also gets a chance to run?

When both tasks have dedicated UART, what is the problem even if context switch happens?

Thanks.

Hello sorry for the late reply, I kept delay’s in between both the tasks, and Task1 is having high priority than Task2
The Tasks definitions are

xTaskCreate(task1, "Task1", 2048, NULL, 2, &Task1);
xTaskCreate(task2, "Task1", 10000, NULL, 1, NULL);

Here In Task1 I am using structure which is declared as

typedef struct GPS_STR
{
  String raw_GPS[10];
};

So, until task2 does its work in between I am storing the GPS_Strings inside the Structure which is declared in Task1 but in structure maximum two strings are declared even UART which is dedicated to GPS is sending the proper GPS_string
Can you tell me why the string is not storing in the structure even The dedicated UART for GPS sending the strings
Task2 is for sending the received GPS strings in JSON format to Server using UART2
Task1 is for receiving GPS_Strings from Hardware using UART1
So, when Task2 does JSON and other stuff, TASK1 is receiving and storing the GPS_Strings in structure but as soon as Task2 moves to HTTP_POST AT commands…through serial monitor Debug Statements I can able to confirm that UART1 is sending the GPS strings properly but it is not been storing in the structure in Task1
Is it that context switching issue???

It is hard to understand from your description. Can you share code snippet to show your problem?

code is too long
I will make the content more clearer for you
First
TASK1 => Fetching GPS strings from hardware which is having dedicated UART(UART1) and these GPS strings are stored in structure that I given in my previous post

Task2 => Taking the structure in which whole strings are stored, from Queue and executing HTTP posting to server using HTTP AT commands
So when I am executing TASK2 HTTP AT commands…The TASK1 GPS strings are not storing in the structure, I just need why its not storing in the structure

If this doesn’t work I will try to add some parts of my code

Can you elaborate on that? Is the task running and not storing to the memory or the task is not running at all? How do you verify that the strings are not getting stored? This is still hard to make a guess about the problem you might be facing and showing some code will be really helpful. You can consider uploading the file too.