int start() { jparse_init(); rest_init(); http_start(); device_init(); #ifdef _DEBUG billing_init(); #endif #ifndef _MSC_VER const char *initrc = initSearch(search_file.c_str()); if (initrc && initrc[0]) { api_log_printf("%s\r\n", initrc); searcher = NULL; } else { searcher = makeSearcher(); } #endif api_listen_tcp(api_tag, host.c_str(), port.c_str(), &handlers); size_t num_cores; #ifdef WIN32 SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); num_cores = sysinfo.dwNumberOfProcessors; #elif MACOS int nm[2]; size_t len = 4; uint32_t count; nm[0] = CTL_HW; nm[1] = HW_AVAILCPU; sysctl(nm, 2, &count, &len, NULL, 0); if(count < 1) { nm[1] = HW_NCPU; sysctl(nm, 2, &count, &len, NULL, 0); if(count < 1) { count = 1; } } num_cores = count; #else num_cores = sysconf(_SC_NPROCESSORS_ONLN); #endif CPUINFO *cpu_info = cpu_get_info(); api_log_printf("[HTTP] CPU INFO: Brand name: %s, cores count: %u, Hyper threads: %s\r\n", cpu_info->vendor.c_str(), num_cores, (cpu_info->hyper_threads) ? "yes" : "no"); thread_pool_init(num_cores - 1); api_log_printf("[HTTP] Started\r\n"); return 0; }
/* * Setup per-CPU domain IDs from information saved in 'cpus'. */ void acpi_pxm_set_cpu_locality(void) { struct cpu_info *cpu; struct pcpu *pc; u_int i; if (srat_physaddr == 0) return; for (i = 0; i < MAXCPU; i++) { if (CPU_ABSENT(i)) continue; pc = pcpu_find(i); KASSERT(pc != NULL, ("no pcpu data for CPU %u", i)); cpu = cpu_get_info(pc); pc->pc_domain = vm_ndomains > 1 ? cpu->domain : 0; CPU_SET(i, &cpuset_domain[pc->pc_domain]); if (bootverbose) printf("SRAT: CPU %u has memory domain %d\n", i, pc->pc_domain); } }