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,16 @@ 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+ match unsafe { libc:: sched_getscheduler ( 0 ) } {
74+ libc:: SCHED_FIFO | libc:: SCHED_RR | libc:: SCHED_DEADLINE => num_cpus_all ( ) ,
75+ _ => available_parallelism ( ) , // error
76+ }
77+ #[ cfg( not( any( target_os = "linux" , target_os = "android" ) ) ) ]
78+ available_parallelism ( )
79+ }
7180 }
7281 } ;
7382
You can’t perform that action at this time.
0 commit comments