帮忙翻译一下下面一段话

来源:百度知道 编辑:UC知道 时间:2024/05/15 00:16:54
Because the default stack size assigned by the linker is 1MB, and 2000 stacks times 1MB per stack equals around 2GB, which is how much address space is available to user-mode programs.

You can try to squeeze more threads into your process by reducing your stack size, which can be done either by tweaking linker options or manually overriding the stack size passed to the CreateThread functions as described in MSDN.
HANDLE h = CreateThread(NULL, 4096, ThreadProc, NULL,
STACK_SIZE_PARAM_IS_A_RESERVATION, &id);
With this change, I was able to squeak in around 13000 threads. While that's certainly better than 2000, it's short of the naive expectation of 500,000 threads. (A thread is using 4KB of stack in 2GB address space.) But you're forgetting the other overhead. Address space allocation granularity is 64KB, so each thread's stack occupies 64KB of address space even if only 4KB of it is used. Plus of course you don't have fre

因为默认的堆栈大小所指定的链接是为1MB ,和2000年栈时代1 MB的每栈等于2 GB的周围,这是多大的地址空间是提供给用户模式的程序。

您可以尝试挤压多个线程到您的进程,减少您的堆栈大小,可以做的调整,无论是连接选项或手动凌驾于堆栈大小传递给createthread职能所描述的MSDN中。
处理为H = createthread (空, 4096 , threadproc ,空,
stack_size_param_is_a_reservation ,及编号) ;
与这种变化,我能squeak在大约13000绪。而这当然优于2000年,它的短期的天真的期望, 50.0万绪。 (一线程是使用4 KB的协议栈在2 GB的地址空间。 ) ,但您忘记了其他的开销。地址空间的分配粒度的64 KB ,所以每个线程的栈中占有的64 KB的地址空间,即使只有4 KB的,它是用来。再加上,当然你没有自由的统治超过所有2GB的地址空间;有系统DLL和其他的东西占领它。
但真正的问题是提出每当有人问, “什么样的人数最多线程的过程,可以创造” ?是“为什么你创造这么多线程,这甚至成为一个问题” ?
“一个线程在每个客户端”模式,是人所共知的不规模超出了十几个客户或如此。如果您要处理多,很多客户同时,你应该提出一个模式,而不是无私奉献,一个线程到用户端,你不是分配一个对象。 (总有一天,我会缪斯对偶之间的线程和对象。 ) Windows提供了I / O完成端口和线程池,以帮助您转换,从一个线程为基础的模式,以工作项目为基础的模式。
请注意,纤维不帮助不大,因为光纤有一个栈,这是地址空间所需要的堆栈,这是限制因素几乎所有的时间。

around 2GB是大约2GB的意思吧