TABLE OF CONTENTS
::pwtk::nice
SYNOPSIS
proc ::pwtk::nice {args} {
PURPOSE
Set or query the niceness value for the execution of programs (aka "nice"). Here is an example of how the program is run in the terminal with the highest niceness (aka nice -19):
nice -19 program.x
or for parallel execution:
nice -19 mpirun -n 8 program.x
The effect of this command is that, for example, with the "::pwtk::nice -19" call, all subsequent calculations will be run with nice -19.
USAGE
Set mode: ::pwtk::nice value Query mode: ::pwtk::nice
ARGUMENTS
- value -- value of the niceness; irrespective of whether negative or positive value is supplied, its magnitude is used and the 'nice' is run as: nice -[expr abs($value)]
RETURN VALUE
The current (absolute) value of the niceness or an empty string if niceness was not set.
SOURCE
variable RUNopt if { [llength $args] == 0 } { return [expr { [info exists RUNopt(NICE)] ? $RUNopt(NICE) : {} }] } elseif { [llength $args] == 1 } { set args [lindex $args 0] if { $args != {} } { if { ! [string is integer $args] } { ::pwtk::error "expecting an integer but got: $args" 1 } set RUNopt(NICE) [expr abs($args)] set RUNopt(NICE_CMD) "nice -$RUNopt(NICE)" } else { set RUNopt(NICE) {} set RUNopt(NICE_CMD) {} } } else { ::pwtk::error "expecting zero or one argument, but got: $args" 1 } return $RUNopt(NICE) }