comparison src/os/unix/ngx_process_cycle.c @ 4549:f31162fefe01

worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
author Ruslan Ermilov <ru@nginx.com>
date Wed, 21 Mar 2012 13:58:51 +0000
parents 9dfe02dd0f11
children 626157fe6f17
comparison
equal deleted inserted replaced
4548:4c1e6cef1453 4549:f31162fefe01
60 volatile ngx_thread_t ngx_threads[NGX_MAX_THREADS]; 60 volatile ngx_thread_t ngx_threads[NGX_MAX_THREADS];
61 ngx_int_t ngx_threads_n; 61 ngx_int_t ngx_threads_n;
62 #endif 62 #endif
63 63
64 64
65 u_long cpu_affinity; 65 uint64_t cpu_affinity;
66 static u_char master_process[] = "master process"; 66 static u_char master_process[] = "master process";
67 67
68 68
69 static ngx_cache_manager_ctx_t ngx_cache_manager_ctx = { 69 static ngx_cache_manager_ctx_t ngx_cache_manager_ctx = {
70 ngx_cache_manager_process_handler, "cache manager process", 0 70 ngx_cache_manager_process_handler, "cache manager process", 0
911 /* fatal */ 911 /* fatal */
912 exit(2); 912 exit(2);
913 } 913 }
914 } 914 }
915 915
916 #if (NGX_HAVE_SCHED_SETAFFINITY)
917
918 if (cpu_affinity) { 916 if (cpu_affinity) {
919 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, 917 ngx_setaffinity(cpu_affinity, cycle->log);
920 "sched_setaffinity(0x%08Xl)", cpu_affinity); 918 }
921
922 if (sched_setaffinity(0, sizeof(cpu_affinity),
923 (cpu_set_t *) &cpu_affinity)
924 == -1)
925 {
926 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
927 "sched_setaffinity(0x%08Xl) failed", cpu_affinity);
928 }
929 }
930
931 #endif
932 919
933 #if (NGX_HAVE_PR_SET_DUMPABLE) 920 #if (NGX_HAVE_PR_SET_DUMPABLE)
934 921
935 /* allow coredump after setuid() in Linux 2.4.x */ 922 /* allow coredump after setuid() in Linux 2.4.x */
936 923