comparison src/os/unix/ngx_posix_init.c @ 4459:ccb2f8e3d08d

Added ngx_ncpu detection for most *nix platforms. This inaccurate detection by using sysconf(_SC_NPROCESSORS_ONLN) can improve usage of the mutex lock optimization on multicore systems.
author Valentin Bartenev <vbart@nginx.com>
date Fri, 10 Feb 2012 11:24:19 +0000
parents d620f497c50f
children 4c36e15651f7
comparison
equal deleted inserted replaced
4458:2d4ff8bd5649 4459:ccb2f8e3d08d
45 ngx_pagesize = getpagesize(); 45 ngx_pagesize = getpagesize();
46 ngx_cacheline_size = NGX_CPU_CACHE_LINE; 46 ngx_cacheline_size = NGX_CPU_CACHE_LINE;
47 47
48 for (n = ngx_pagesize; n >>= 1; ngx_pagesize_shift++) { /* void */ } 48 for (n = ngx_pagesize; n >>= 1; ngx_pagesize_shift++) { /* void */ }
49 49
50 #if (NGX_HAVE_SC_NPROCESSORS_ONLN)
50 if (ngx_ncpu == 0) { 51 if (ngx_ncpu == 0) {
52 ngx_ncpu = sysconf(_SC_NPROCESSORS_ONLN);
53 }
54 #endif
55
56 if (ngx_ncpu < 1) {
51 ngx_ncpu = 1; 57 ngx_ncpu = 1;
52 } 58 }
53 59
54 ngx_cpuinfo(); 60 ngx_cpuinfo();
55 61