How Tasks are distributed between Cores of ESP32S

No message comes from task0.

This is the sketch I am running based on your suggestion:

TaskHandle_t task0Handle;

void setup()
{
  pinMode(2, OUTPUT);
  pinMode(23, OUTPUT);

  Serial.begin(115200);

  //create a task on core 0 that will be execute task1Func() with priority 10
  xTaskCreatePinnedToCore
  (
    task0,        /* Task function. */
    "Task1",      /* name of task. */
    10000,        /* Stack size of task */
    nullptr,      /* parameter of the task */
    5,            /* priority of the task */
    &task0Handle, /* Task handle to keep track of created task */
    0
  );           /* pin task to core 0 */
}


void task0( void *pvParameters )
{
  Serial.print("Task running on core: ");
  Serial.println(xPortGetCoreID());
  for (;;)
  {
    digitalWrite(2, HIGH);
    delay(1000);
    digitalWrite(2, LOW);
    delay(300);
  }
}

void loop()
{
  //Serial.print("Task running on core: ");  //this is ok; shows Core 1
  //Serial.println(xPortGetCoreID());
  digitalWrite(23, LOW);
  delay(250);
  digitalWrite(23, HIGH);
  delay(250);
}

probably the Serial port is not fully initialized yet when the task is forked

try with

TaskHandle_t task0Handle;

void setup()
{
  pinMode(2, OUTPUT);
  pinMode(23, OUTPUT);

  Serial.begin(115200);

  //create a task on core 0 that will be execute task1Func() with priority 10
  xTaskCreatePinnedToCore
  (
    task0,        /* Task function. */
    "Task1",      /* name of task. */
    10000,        /* Stack size of task */
    nullptr,      /* parameter of the task */
    5,            /* priority of the task */
    &task0Handle, /* Task handle to keep track of created task */
    0
  );           /* pin task to core 0 */
}


void task0( void *pvParameters )
{
  for (;;)
  {
    digitalWrite(2, HIGH);
    delay(1000);
    digitalWrite(2, LOW);
    delay(300);
    Serial.print(" another blink from Task running on core: ");
    Serial.println(xPortGetCoreID());
  }
}

void loop()
{
  digitalWrite(23, LOW);
  delay(250);
  digitalWrite(23, HIGH);
  delay(250);
}

Working fine! Now, getting message from task0 indicating Core 0.
Output:

 another blink from Task running on core: 0
 another blink from Task running on core: 0

Thanks for providing the codes.

great - seems to work as advertised :wink:

In common English usage, "bureaucratic" is mostly used in a pejorative sense.

If you mean "manufacturers' data sheets", you should really say that.

(And, of course, the answer is "Yes, you should always consult the manufacturers' data sheets")

It seems that you first need to gain a rudimentary understanding of how a real time, multi-tasking operating system works. I recommend that you start by reading "Mastering the FreeRTOS Real Time Kernel - a Hands On Tutorial Guide" located HERE.

Then, look at changes made to vanilla FreeRTOS by Espresif to support multiple cores, Starting Here.

Thank you very much for encouraging me to undertake readings on "Computer Operating System" especially on multi-tasking one. I have had some exposure on single-tasking/multi-tasking OS from the Masters Course Work about 30 years ago most of which must had been faded in the meantime. Now, I will have the opportunity to make an objective review on the functioning of the same by virtue of ESP32 Platform.

Yes, absolutely - the manufacturer's datasheet is the definitive source.

And, whenever possible, it's best to get the datasheet direct from the manufacturer - 3rd-party sites are often out-of-date.

There are data sheets and yet a manufacturer prepares application notes to boost the usages of their product (s) because of the bureaucratic write-up style of the data sheets from which a potential user can not easily infer required information for building a prototype.

If we recall Intel's approach -- when they launched 8085 Microprocessor, they concurrently released SDK-85 Development Kit and they did the same thing for 8086 by releasing SDK-86.

For the case of Microchip, we don't see many countable application notes in favor of their popular ATmega328P MCU except the voluminous data sheets which are not much useful for inexperienced users.

Likewise, we don't see many user friendly application notes from arduino.cc in favor of the popular Arduino UNO Learning Kit except some IDE Examples and Arduino Reference Manual.

We (the learners) are lucky to have a number of Tutors who post online tutorials for Arduino most of which can be followed against a check list to reach at the desired result.

Now-a-days, ChatGPT (at least to me) supplies useful information in simple English though only 70% is correct on an average in the view of an anonymous Arduino Forum Member.

au contraire:

Please stop using words which you don't understand.

Data sheets list technical details, nothing about bureaucratic administration.

To be fair, he further qualified what he had in mind

and @awneil

there is such a thing as bureaucratic writing style and studies about it (here is one)

he is expressing his perception of those documents, you might disagree and find them easy and pleasant to read, but I don't see why you would ask him not to use that particular wording...

my 2cts

Simplified technical English, as used in data sheets, is easy to read and understand, even for non-native English speakers. It is not pleasant to read for newbies, some technical knowledge is required.

Make that "well-written datasheets". In 35+ years of engineering I've had to deal with plenty of datasheets that are absolute crap. That's where a good FAE can be worth his weight in gold.

I worked overseas for many years with a renowned Oil Service Company who maintained a dedicated department/team at the Head Quarter to prepare FAE (Field Application Engineering Manuals) to minimize down time by providing quick indices and measures for the operations of the equipment as well as trouble shooting and repairing.

There exist good and bad data sheets as well as FAEs. No prejudice about both in general.

@noiasca, nice diagram. Please provide a link to its source.
Thanks.

page 2 of the datasheet

Hah ... just had that open and completely blew by it. Thanks.