Embedded Basics – Threads vs Tasks

The 32-bit microcontroller has been increasing in capabilities and decreasing in cost which has resulted in real-time operating systems becoming the dominant scheduler in many embedded systems. While there are more than a hundred different RTOS flavors out on the market, engineers sometimes struggle with basic terminology. Take for example threads and task which under many circumstances are used synonymously yet signify slightly different concepts.

The ThreadX User Guide version 5 defines an embedded task as “a semi-independent portion of the application that carries out a specific duty.” In other words, a task tends to be a high level duty that is carried out by the application. The word task is often used in such a generic way that it can be difficult to determine if a developer is referring to a program segment or a completely separate and loadable program.

A thread on the other hand is defined as “a semi-independent program segment that executes within a process”. For embedded software developers working with microcontrollers, a process is essentially the entire application that runs on the system. A thread is then a small program that has a specific function and purpose within the overall application. Threads tend to be lower level than tasks and have minimal overhead.

Most RTOSes that one encounters are probably actually thread scheduler and not task schedulers but for now many developers just use the terms interchangeably. It’s good to know though that there is a subtle difference.

Share >

2 thoughts on “Embedded Basics – Threads vs Tasks

  1. First thanks for post, Threads vs Tasks is kinda standard and very confusing thing, at least for me.

    In you blog do you mean that we never work with task in most of RTOS, its all threads? Like in FreeRTOS xTaskCreate() api creates a thread not task?

    Can you tell difference in both using some real time embedded example?

    • It is a confusing term because at the microcontroller level, threads and tasks are the same thing. People use them interchangeably and they mean the same thing. If you move into general computing applications, there is a slight difference. If you look at ThreadX which competes with FreeRTOS, ThreadX uses the terms threads while FreeRTOS uses tasks. They are doing the same thing though. I hope that helps!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.