- 论坛徽章:
- 0
|
不是很清楚你修改CPU Tick的目的是什么,
如果你想改变tru64分配给process/thread的时间片, 或减少context switches的话, 可以试试修改round_robin_switch_rate
#sysconfig -q proc | grep round_robin_switch_rate
#man sys_attrs_proc
round_robin_switch_rate
A value that determines (per second of CPU time) the number of context
switches that can occur between processes with the same priority and
the timeslice allotted to each process.
Default value: 0 (100 context switches per second)
Minimum value: 0
Maximum value: hz
The system uses the following formula to compute timeslice:
timeslice = hz / number_context_switches
The hz value is the timer interrupt frequency (hertz) for one second of
CPU time. This value is dependent on hardware and is typically 1024 or
1200. (To determine the hz value on a particular system, programmers
can use the getsysinfo() call with GSI_CLK_TCK as the op parameter.)
If round_robin_switch_rate is either 0 (zero) or greater than hz, the
system uses 100 for number_context_switches. For example, if hz is
1024, the resulting timeslice is 10 milliseconds, and if hz is 1200,
the resulting timeslice is 12 milliseconds:
timeslice = 1024 / 100 = 10
timeslice = 1200 / 100 = 12
If round_robin_switch_rate is greater than zero and less than or equal
to hz, then number_context_switches is set to round_robin_switch_rate.
For example, changing round_robin_switch_rate from 0 to 20 decreases
the number of context switches and increases timeslice by a factor of
five:
timeslice = 1024 / 20 = 51
timeslice = 1200 / 20 = 60
Context switching carries a certain amount of CPU overhead. If a CPU
consistently handles many large jobs that do not complete quickly, a
larger timeslice (and fewer context switches) may improve throughput.
However, the tradeoff is reduced response time for any interactive
processes that the CPU handles.
Decrements the current thread’s quantum. If this exhausts the thread’s quantum,
a new thread may get scheduled. Can invoke the update_priority() routine to update the thread’s priority.
The quantum defaults to 1/100 of a second. Its actual calculation is done in src/kernel/kern/sched_prim.c:
if ((round_robin_switch_rate > 0) && (round_robin_switch_rate <= hz))
min_quantum = hz / round_robin_switch_rate;
else
min_quantum = hz / 100;
where hz (hertz) is a global value representing the number of CPU ticks per second and round_robin_switch_rate is configurable via /etc/sysconfigtab. |
|