Thank you guys for your help.
christop:
Yes this is for the Linux Kernel. I am really interested using the fixed point you suggested. My research partner and I have talked about this filter function; however, we are not sure how to implement this function. Though, the code below shows some idea. I also like your example about treating a u32 as a 16-bit integer and 16-bit fraction. Though how would you create this, because my knowledge is u32 is an unsigned 32 bits of integer, but still interesting.
Code:
/*new "fixed" function -----------------------------------------*/global int cy; //comment: use global variable cy .
global int x, int y;
int filter(int x, int y)
{
cy = 10000*a*x + b*cy; // comment: cy = 10000*y; x is input;
y = cy/10000; //comment: 1>a >0; 1>b>0;
return y;
}
/*----------------------------*/
grumpy:
Thank you for posting that link. In that blog it says something about using two functions, kernel_fpu_begin() and kernel_fpu_end(), to use the floating point in the kernel. This is amazing and I don't have to make a fixed point function (no offense christop lol). In the blog it said that to use these functions just put the floating point codes between those functions. I have posted a code just to make sure I am doing this correctly, am I?
Code:
static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, u32 in_flight){
kernel_fpu_begin();
struct tcp_sock *tp = tcp_sk(sk);
struct vegas *vegas = inet_csk_ca(sk);
int target_queue_size;
float rho, step_size;
double avgRTT_Mult, rtt_Mult;
rho = 0.5;
step_size = 0.1;
target_queue_size = 100;
avgRTT_Mult = 0.99609375; //(255/256)
rtt_Mult = 0.00390625; //(1/256)
.
.
.
avgRTT = (avgRTT_Mult*avgRtt) + (rtt_Mult*rtt);
.
.
.
.
kernel_fpu_end();
}