80,352
社区成员
发帖
与我相关
我的任务
分享
/**
* This is an attempt to get the PIDs to roll over faster. Threads use up
* PIDs on Android and spawning a new thread is much faster than having
* another service spawned as we are doing in this test.
*/
private static void wastePids(int firstPid, int previousPid) {
int distance = (firstPid - previousPid + MAX_PID) % MAX_PID;
// Don't waste PIDs if we're close to wrap-around to improve odds of
// collision.
if ((distance < PID_WASTING_SKIP_LOWER) || (MAX_PID - distance < PID_WASTING_SKIP_UPPER)) {
return;
}
for (int i = 0; i < distance; i++) {
Thread t = new Thread();
t.start();
}
}
for (int i = 0; i < distance; i++) {
Thread t = new Thread();
t.start();
}
static int alloc_pidmap(struct pid_namespace *pid_ns)
{
int i, offset, max_scan, pid, last = pid_ns->last_pid; //取出last_pid
struct pidmap *map;
pid = last + 1; //这里last+1,取得备选pid
//如果pid到了pidmax,那么重头开始寻找可用的pid,从RESERVED_PIDS开始,保留RESERVED_PIDS之前的pid号,默认300
if (pid >= pid_max)
pid = RESERVED_PIDS;
……
}
说明Pid是从底按照次序往上分配的。
基本可以解释这个CTS的测试原理了,谢谢你的回复!