Re: [PATCH 1/2] Replace definition of variable sum from int to unsigned long

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 09, 2017 at 01:08:30PM +0800, Junchang Wang wrote:
>  The maximum size of integer variable on 64bit machines is 2^31. Suppose the
>  writer takes 5 nanosecond to increase the counter by one, the result wraps
>  around in about 10 seconds.
> 
> Signed-off-by: Junchang Wang <junchangwang@xxxxxxxxx>

Good catch, queued!

							Thanx, Paul

> ---
>  CodeSamples/count/count_stat_eventual.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/CodeSamples/count/count_stat_eventual.c b/CodeSamples/count/count_stat_eventual.c
> index 75a0ca9..059ab8b 100644
> --- a/CodeSamples/count/count_stat_eventual.c
> +++ b/CodeSamples/count/count_stat_eventual.c
> @@ -38,7 +38,7 @@ unsigned long read_count(void)
>  void *eventual(void *arg)
>  {
>  	int t;
> -	int sum;
> +	unsigned long sum;
> 
>  	while (stopflag < 3) {
>  		sum = 0;
> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe perfbook" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

--
To unsubscribe from this list: send the line "unsubscribe perfbook" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux