Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Callback context on ESP32? #657

Closed
Closed

Description

@ashley-schaeffer

I'm running ESPAsyncWebServer on ESP32, with AsyncTCP obviously.
I don't create any FreeRTOS tasks myself so I only have the Arduino loop() checking for some flags. Those flags are set from inside callbacks I passed to the ESPAsyncWebServer and AsyncTCP libraries.

However I only recently took a closer look at the source of the AsyncTCP library and realized a new task is created for calling the user supplied callbacks. Am I right in thinking that I should synchronize access between any variables accessed by both the loop() function and the callbacks (both in ESPAsyncWebServer and AsyncTCP) to prevent possible race conditions?

I'm asking because I haven't really seen this mentioned explicitly somewhere. I'm guessing it's only an "issue" on the ESP32?

Activity

  1. BlueAndi commented on Dec 10, 2019

    @BlueAndi

    Yes, you are right. The loop() is running in a task with prio 1 and the ESPAsyncWebserver is running in a separste task with prio 3. This means you have to consider concurreny access.

  2. me21 commented on Dec 24, 2019

    @me21
    Contributor

    ...unless variable access is atomic, that is, variable type is primitive (i.e. bool, uint32), you only read or write value (not read-modify-write) and both tasks use the same CPU core, if I understand correctly

  3. mamama1 commented on Jan 18, 2020

    @mamama1

    hi,

    this is kinda blowing my mind atm. could someone please be so kind and provide a simple example which demonstrates this issue? I might currently experience it but I'm not sure.

    Thanks!

  4. stale commented on Mar 18, 2020

    @stale

    [STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

  5. stale commented on Apr 1, 2020

    @stale

    [STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions