Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ch2.13 一句话很奇怪不会翻译 #12

Open
laixintao opened this issue Sep 30, 2017 · 4 comments
Open

ch2.13 一句话很奇怪不会翻译 #12

laixintao opened this issue Sep 30, 2017 · 4 comments

Comments

@laixintao
Copy link
Owner

We have begun to see a better result in the multithreading case. In particular, we've noted how the threaded execution is half time-consuming if we compare it with the non_threaded one. Let's remember that in real life, we would not use threads as a benchmark. Typically, we would put the threads in a queue, pull them out, and perform other tasks. Having multiple threads that execute the same function although useful in certain cases, is not a common use case for a concurrent program, unless it divides the data in the input.

看不懂加粗加斜的这句话。位置第三次测试的结果解释的地方。

@Roon2300
Copy link

“other tasks” 指的是thread的具体任务吧?
拙译:“通常的并发场景里,我们先把各个任务线程放进队列排队,然后依次取出队首的线程,执行线程任务。”

全译:“我们开始看到多线程方式的结果更好。特别是相对于非多线程方式来说,多线程方式只耗费了一半左右的时间。所以在实际情况中,我们不会将多线程的耗时作为时间比较基准。通常的并发场景里,我们先把各个任务线程放进队列排队,然后依次取出队首的线程,执行线程任务。少数场景下,我们也可以同时使用多个线程执行同一函数,不过这种方式必须要先将输入数据按照线程进行独立划分后才能进行。”

@laixintao
Copy link
Owner Author

@Roon2300 R

Hi,感谢帮忙。不过我觉得不太说的过去。这里测试的是用多线程读文件,结果是多线程表现良好。
http://python-parallel-programmning-cookbook.readthedocs.io/zh_CN/latest/chapter2/13_Evaluating_the_performance_of_multithread_applications.html

然后依次取出队首的线程,执行线程任务。

这样说的话理解起来是顺序执行每一个线程。但是结合上下文,我觉得原文想表达的应该是线程遇到IO的时候就暂停执行,然后去执行其他的线程(perform other tasks),等这里的IO好了再回来执行这个线程。

@Roon2300
Copy link

@laixintao
我觉得你说的是正确的。百度翻译:pull them out -> tirateli fuori(意呆利语) -> 带他们出去。
意呆利式英文读起来总感觉前言不搭后语的。。。

PS:依次取队首线程执行并不代表是顺序的,比如优先队列就不是。

@wizardforcel
Copy link

wizardforcel commented Mar 30, 2018

@laixintao

进程和线程调度的确是靠队列的。时间片走完之后,计时器向总线发中断,CPU接到之后切到内核态,把队列头部的线程移到队尾,上下文保存好,然后把下一个设为活动的,并取出上下文。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants