File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33// For the full copyright and license information, please view the LICENSE
44// file that was distributed with this source code.
55
6- // spell-checker:ignore (ToDO) NPROCESSORS nprocs numstr sysconf
6+ // spell-checker:ignore (ToDO) NPROCESSORS SCHED getscheduler nprocs numstr sched sysconf
77
88use clap:: { Arg , ArgAction , Command } ;
99use std:: io:: { Write , stdout} ;
@@ -67,7 +67,23 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
6767 }
6868 // the variable 'OMP_NUM_THREADS' doesn't exist
6969 // fallback to the regular CPU detection
70- Err ( _) => available_parallelism ( ) ,
70+ Err ( _) => {
71+ // ignore quota under some schedulers
72+ #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
73+ {
74+ let policy = unsafe { libc:: sched_getscheduler ( 0 ) } ;
75+ if policy == libc:: SCHED_FIFO
76+ || policy == libc:: SCHED_RR
77+ || policy == libc:: SCHED_DEADLINE
78+ {
79+ num_cpus_all ( )
80+ } else {
81+ available_parallelism ( )
82+ }
83+ }
84+ #[ cfg( not( any( target_os = "linux" , target_os = "android" ) ) ) ]
85+ available_parallelism ( )
86+ }
7187 }
7288 } ;
7389
You can’t perform that action at this time.
0 commit comments