BASICS: What's the difference between vTask... and xTask...?

Good Morning.

I’ve been already using some tools from FreeRTOS in Espressif ESP32 applications. Now I’m starting to read for learning it better.

My first question regards the prefix “x” or “v” attached to tasks, queues, etc.

What do they mean?

Thank you.

The type the function returns. V is void, doesn’t return any value directly, only via pointer parameters.

Thank you Richard.

Just to double check, I could declare a xTask as something else than void and get a return from it? Like:

bool xTaskWhatever (void *pvParameters)
return true;

Serial.print( "Status is " ); Serial.print( xTaskWhatever );

Thank you.

You can write whatever you want in the application code. Richard was talking about the FreeRTOS naming conventions which you can read here- FreeRTOS - Free RTOS Coding Standard and Style Guide


Functions in the api that begin with v return void. If the next word in the name is Task, then they are task related and are defined in task.h

Your functions that define tasks do not need to use this convention, and I would actually suggest NOT doing so, to avoid naming issues.

Tasks themselves never ‘return’ a value as tasks should never return (if they are done, they should just delete themselves). Also, just calling a function with a name with Task, won’t make it a task. You make a task by calling one of the xTaskCreate functions.

But then what is a xTask ment to be?

This page was already linked - little point writing the same text here.

Where did you get this xTask example from ?
Is this an example of a task function as given to xTaskCreate ? Then it’s not exactly right as you can see in the API documentation This page describes the RTOS xTaskCreate() FreeRTOS API function which is part of the RTOS task control API. FreeRTOS is a professional grade, small footprint, open source RTOS for microcontrollers. or e.g in this example Writing RTOS tasks in FreeRTOS - implementing tasks as forever loops.

You mean I’ll only find “xTask…” as RTOS predefined macros which return something, such as xTaskCreate?

No - as @richard-damon already pointed out it’s just a simplified (I’d say a good, pragmatic) hungarian notation. Nothing special - just a naming convention.
I was bit confused by

My bad :wink:

Sorry. I couldn’t get it!

What would a “xTask…” represent?

xTask… represents any function whose name begins with the letters xTask.

The x represents the type of value it returns, it is something, but more than just a primitive type. (often a handle of some type)

Task indicates that it is from Task,h

… is the rest of the name, not specified in this case.