4 Replies Latest reply on Oct 5, 2020 10:33 PM by ToKo_4602001

    CYW20819 callback task priority


      There are some callback functions to be evoked by base firmware (BT Stack) or libraries.


      For instance

      Main:     wiced_bt_stack_init(app_callback, init_cfg_param(), wiced_bt_cfg_buf_pools);

      HCI:      wiced_bt_dev_register_hci_trace(hci_cback);

      Inquiry:     wiced_bt_start_inquiry(&inq_params, inquiry_result_cback);

      Timer:     wiced_init_timer(&timer, timer_cback, 0, WICED_SECONDS_TIMER);


      I would like to know what level priority these callback functions run on.

      For example, "same as lowest priority task", "same as highest priority task", "same as interrupt level", and so on.


      If a call back is evoked during a task is executed, does the function preempt the task?

      Can we execute safely long time processing in a callback function?




        • 1. Re: CYW20819 callback task priority



          All callbacks have same priority since it runs within the application thread. The stack generates events and calls the registered callback functions to take appropriate actions. These callbacks are serialized one after the other. So it won't preempt the tasks.




          • 2. Re: CYW20819 callback task priority

            Thank you for your explanation.


            I understand that the app_callback() which is input into wiced_bt_stack_init() and BT stack callbacks have same priority and these are serialized.


            Please let me add a question.

            I can create new tasks designating given priority as below.


            task_handle_uart_tx = wiced_rtos_create_thread();










            In this case, which has higher priority, callback functions or the tasks added?



            • 3. Re: CYW20819 callback task priority



              Usually idle task has the lowest priority (i.e. 0) in WICED RTOS implementation. If a new application task is created with higher priority, CPU chooses it to run first.


              "Higher priority tasks will always run at the expense of lower priority tasks, so it is still important to yield control to give lower priority tasks a turn. If not, tasks that don't yield control will prevent lower or equal priority tasks from running at all. As an example, the watch dog timer thread is very low priority (it runs in the idle task) so if your tasks don't yield you will likely see watchdog resets. It is good practice to have some form of yield control mechanism in every thread to prevent such situations"

              Reference: CypressAcademy_WBT101_Files/WBT101-03-RTOS.pdf at master · cypresssemiconductorco/CypressAcademy_WBT101_Files · GitHub




              • 4. Re: CYW20819 callback task priority

                Thank you for your comment.


                However I want to know the ordering of priority of the followings.


                (A) A task [Priority setting: 0 to 7]

                     created by using wiced_rtos_create_thread(), wiced_rtos_init_thread().


                (B)Wiced BT stack callback [app_callback]

                    created by using wiced_bt_stack_init(app_callback, init_cfg_param(), buf_pools);


                (C)Interrupt [According to your comment on ]



                Which has higher priority a task [Priority setting: 0] or Wiced BT stack callback?

                Which has higher priority a task [Priority setting: 7] or Wiced BT stack callback?