In the original design, when doing the fork operation, the
tss.ldt and tss.tr in PCB are used to save selectors in LDTR and
TR. According to the original algorithm, the selector of the LDT of
a process may exceed its 16-bit limit. So we use extra variable
tss.__ldth with tss.ldt to save the selector. Since tss.__ldth is
not used in Linux 2.2.x, our modification won't break the kernel.
The saving of LDTR and TR now works like this:

After doing these, we have broken through the maximum process
number restriction. We can even add an extra parameter in the lilo
configuration file to set this number dynamically. The following
line will set the maximum process number to 40,000, which is much
greater than 4,090:

Append = "nrtasks=40000"

Conclusion

According to the above solution, we can set the upper limit
of concurrent process number to 2G, in theory. But in practice,
hardware and OS still limit this number. When creating a new
process, the kernel will allocate memory for it, like this:

So if the computer has 1G memory and uses five pages per
process where the OS uses 20M of memory, the maximum process number
can be:

(1G - 20M) / 20K = 51404 ~= 50,000

More practically, a process will use 30K memory at least, so the
number now is:

50000 * (2/3) = 33,000

This number is still much greater than 4,090.

Zhang Yong
(leon@xteamlinux.com.cn) is a senior
software engineer of Xteam Software Co., Ltd. His work covers many
aspects of Linux, including kernel development, Linux I18N&I10N
and network applications, etc. He is currently focusing on the
upcoming new release of XteamServer, which is a high-end server
solution based on Linux. Xteam Software Co., Ltd. is also the
vendor of XteamLinux and XteamLindows. They are both the most
popular Linux Distributions in China. For more information, please
visit
http://www.xteamlinux.com.cn/.