Mike wrote:
> By cat'ing each task pid
> (including init's) to root (or mikeg) task's file?
I guess you meant:
echo'ing
not:
cat'ing
Lets say for example one has cpusets:
/dev/cpuset
/dev/cpuset/foo
One cannot move the tasks in 'foo' to the top (root) cpuset by doing:
cat < /dev/cpuset/foo/tasks > /dev/cpuset/tasks # fails
That cat fails because the tasks file has to be written one pid at a
time, not in big buffered writes of multiple lines like cat does.
The usual code for doing this move is:
while read i
do
/bin/echo $i > /dev/cpuset/tasks
done < /dev/cpuset/foo/tasks
There is a cute trick that lets you move all the tasks in one cpuset to
another cpuset in a one-liner, by making use of the "sed -u" unbuffered
option:
sed -nu p < /dev/cpuset/foo/tasks > /dev/cpuset/tasks # works
For serious production work, the above is still racey. A task could be
added to the 'foo' cpuset when another task in 'foo' forks while the
copying is being done. The following loop minimizes (doesn't perfectly
solve) this race:
while test -s /dev/cpsuet/foo/tasks
do
sed -nu p < /dev/cpuset/foo/tasks > /dev/cpuset/tasks
done
The above loop is still theoretically racey with fork, but seems to
work in practice.
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.925.600.0401
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]