Getting the number of processors in emacs

Is there a good cross-platform method for determining the number of processors a machine has in elisp? I try to have my configuration automatically detect some build parameters and would like it to automatically use the number of processors + 1. Grepping / proc / cpuinfo is not a solution for me because it will not work on Windows.

+4
source share
1 answer

Emacs 24.3 Lisp does not have access to this information. Your options would seem to include:

  • An Elisp library entry that uses the SYSTEM-TYPE value to select a system method for counting the number of processors;
  • Emacs C , , Emacs, Lisp.

, , . , :

  • system-cores.el, (system-cores :physical), , (system-cores :logical) (system-cores), alist, .

:

  • PROCESS-LINES. , SYSTEM-CORES, SYSTEM-CORES . (, , (getenv "PATH") /usr/sbin, PROCESS-LINES " : , system_profiler".)
  • , GNU/Linux (- /proc/cpuinfo, ), Windows NT ( , 2000, XP ) Darwin (OS X, 10,8, 10.2). , , .

    , , , BSD, BSD, , , - - , sysctls, SYSTEM-CORES-SYSCTL.

Linux, Windows OS X, ! , . , , , . , , :

  • , .
  • M-: system-type Emacs
  • M-: system-configuration Emacs

.

: :cores :processors :physical :logical ; , , - .

: @lunaryorn, (split-string (shell-command-to-string ...)) (process-lines ...). , , , .

+8

All Articles