On Thursday 17 March 2011 23:40:06 hlabishi kobo wrote:
Hi thank you very much for your suggestions Sven, they
were really
helpful. i actually now put the below code down which i am still busy
trying to test it.
int weighted_bit_packet_count(TYPE_OF_WORD *seq_bits)
{
int i,check, count = 0;
int j;
//TYPE_OF_WORD *word;
int word;
for (i = 0; i < NUM_WORDS; i++) {
word = seq_bits[i];
for (j = 0; j < 32; j++){
check = (word & (1 << j)) >> j;
if (check == 1)
count += j;
}
printk("our count is %d\n", count);
return count;
}
//printk("our count is %d\n", count);
//return count;
}
When i am using it on two PC's my ping seems to be recording much
delay. I will appreciate your feedback in this regard.
Thank you and kind Regards
Ehrm, you know that you ignore the fact that seq_bits[i] may be 64 bits? And
you only calculate the weighted sum of a single "word" (which you static
casted to int....?) and not all words. And the sum is still wrong weighted
(you still give zero weight for the newest one and increase the weight for the
older). And the way you check the bits is even for a sequential implementation
overly complex. And it is normal that printk heavily increase the amount of
time... maybe you meant that by delay.
Sry, I have really no idea what I should say to it.
Regards,
Sven