- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Regards,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The BT stack will be having highest priority if we compared it with the application task.[Priority setting: 0 to 7]
The idle thread (when the device is not doing any job) has the lowest priority.
All interrupts are serialized and called sequentially.
Thanks,
-Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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.
Thanks,
-Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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();
wiced_rtos_init_thread(task_handle_uart_tx,
TASK_PRIORITY_UART_TX,
TASK_NAME_UART_TX,
task_uart_tx,
TASK_STACK_SIZE_UART_TX,
NULL);
--------------------------------------------------------------------
In this case, which has higher priority, callback functions or the tasks added?
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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"
Thanks,
-Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 2020/09/29, it is same as the priority of Wiced BT stack callback]
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?
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The BT stack will be having highest priority if we compared it with the application task.[Priority setting: 0 to 7]
The idle thread (when the device is not doing any job) has the lowest priority.
All interrupts are serialized and called sequentially.
Thanks,
-Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for all the information.