You are not logged in.
Hi,
I used the following formula to calculate the draining time of the buffer periodically using a scheduler in wlan_mac_ap.c . When I use xil_printf() to print the variable "t_drain", I found different results from manual calculation.
t_drain = (queue_num_queued(queue_sel) * 1428 * 8000000) / (active_bss_info->members.length * rate);
t_drain is defined as u64 local variable.
rate is defined as u32 local variable.
For example:
Queue ID: 2 - Active BSS: 1 - Rate: 27262976 - Queued: 83
Time to Drain: 121 which is not consistent with the right result.
I can't figure out what is the problem.
Offline
The numerator in your calculation exceeds 2^32 (1428 * 8000000 > 2^33). When the compiler interprets the constants as int values (the default for integer constants when no type is specified) the numerator calculation wraps, leading to the unexpected division output. Try casting each value in the expression as a (u64) so the compiler knows it should use 64-bit arithmetic for all steps of the calculation.
Offline
Problem solved. Thank you.
Offline