Tor 0.4.9.0-alpha-dev
Macros | Functions
numcpus.c File Reference

Compute the number of CPUs configured on this system. More...

#include "orconfig.h"
#include "lib/thread/numcpus.h"
#include "lib/log/log.h"
#include "lib/log/util_bug.h"
#include <stdlib.h>

Go to the source code of this file.

Macros

#define MAX_DETECTABLE_CPUS   128
 

Functions

static int compute_num_cpus_impl (void)
 
int compute_num_cpus (void)
 

Detailed Description

Compute the number of CPUs configured on this system.

Definition in file numcpus.c.

Macro Definition Documentation

◆ MAX_DETECTABLE_CPUS

#define MAX_DETECTABLE_CPUS   128

This is an arbitrary number but at this point in time, it is not that uncommon to see servers up to that amount of CPUs. Most servers will likely be around 16 to 32 cores now. Lets take advantage of large machines! The "NumCPUs" torrc option overrides this maximum.

Definition at line 77 of file numcpus.c.

Function Documentation

◆ compute_num_cpus()

int compute_num_cpus ( void  )

Return how many CPUs we are running with. We assume that nobody is using hot-swappable CPUs, so we don't recompute this after the first time. Return -1 if we don't know how to tell the number of CPUs on this system.

Definition at line 85 of file numcpus.c.

Referenced by get_num_cpus().

◆ compute_num_cpus_impl()

static int compute_num_cpus_impl ( void  )
static

Implementation logic for compute_num_cpus().

Definition at line 27 of file numcpus.c.

Referenced by compute_num_cpus().