Re: sched: about vruntime overflow

From: Peter Zijlstra
Date: Tue Jul 07 2015 - 05:10:44 EST


On Tue, Jul 07, 2015 at 08:05:50AM +0000, Gaohaifeng (A) wrote:
> int main()
> {
> unsigned char a,b;
> a=251;
> b=254;
> b +=5; // b will overflow
> printf("a=%u \n",a);
> printf("b=%u \n",b);
> printf("(a-b<0)=%d\n",(a-b)<0);

If you look at entity_before() you'll notice that the correct statement
would be:

printf("(a-b<0)=%d\n",(signed char)(a-b)<0);

> printf("(a-b<0)=%d\n",((unsigned char)(a-250)-(unsigned char)(b-250)<0));
> return 0;
> }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/