Mercurial > hg > nginx
diff 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 |
line wrap: on
line diff
--- a/src/os/unix/ngx_posix_init.c +++ b/src/os/unix/ngx_posix_init.c @@ -47,7 +47,13 @@ ngx_os_init(ngx_log_t *log) for (n = ngx_pagesize; n >>= 1; ngx_pagesize_shift++) { /* void */ } +#if (NGX_HAVE_SC_NPROCESSORS_ONLN) if (ngx_ncpu == 0) { + ngx_ncpu = sysconf(_SC_NPROCESSORS_ONLN); + } +#endif + + if (ngx_ncpu < 1) { ngx_ncpu = 1; }