线程切换可以在单个进程内部发生,也可以跨进程发生。
Thread switches can occur either inside of a single process or across processes.
争用同步之所以慢,是因为它涉及多个线程切换和系统调用。
Contended synchronizations are slow because they involve multiple thread switches and system calls.
当一个线程向另一个线程请求信息时,就可能引起线程切换。
One thread asking another for information can cause a thread switch, or one thread preempting another can cause a thread switch.
并且当它确实执行了线程切换时,每次运行程序时它往往都在同一个位置进行切换。
And when it does perform a thread switch, it tends to do it in the same place whenever you run the program.
如果同步时还发生锁定争用,那么性能上付出的代价会大得多,因为会需要几个线程切换和系统调用。
If the synchronization actually requires contending for the lock, the performance penalty is substantially greater, as there will be several thread switches and system calls required.
并行处理150个线程对于一个处理器来说负担很大,大部分时间都消耗在线程切换上。
Processing 150 threads in parallel is rather much for one processor, which will spend a lot of time just switching between these threads.
解释程序中的函数中若使用这标签变量,那么它能被存到线程代码中以获得高效率的线程切换。
The labels within the interpreter function can be stored in the threaded code for super-fast dispatching.
与此类似,由父线程切换的 num_proc1的值导致了克隆线程中的转移的错误预测。
Similarly, toggling the value of num_proc1 by the parent thread causes branch misprediction in the clone thread.
这样避免了在并发度较高的情况下,频繁的线程切换带来的大量系统开销,提高了服务器的性能。
It avoids the large system overhead of Thread switching frequency under high concurrency, and improves the server's performance.
运行在另一个处理器上的克隆的线程切换num_proc1的值(并且根据由另一个处理器修改的该变量的值进行转移)。
The cloned thread running on another processor toggles the value of num_proc2 based on the value of num_proc1 (and branches based on the value of the variable modified by another process).
MacRuby 0.6发布之后,用户发现了一个问题,在运行某代码段的时候,从后台线程切换到主线程会导致程序崩溃。
One issue that was found after the release of MacRuby 0.6 seems to cause problems with scheduling a block to run on the main thread from a background thread.
个线程对于一个处理器来说负担很大,大部分时间都消耗在线程切换上。在这种情况下,你必须增加更多的处理器来分担负荷。
For example, a quad-processor server would need to process only 37 threads per processor-a more reasonable amount. Scaling beyond this can be done.
应用程序代码接收新的主题,然后调用 WSSubject.setRunAsSubject(returned_subject)方法为当前线程切换标识。
The application code receives the new subject, then invokes the WSSubject.setRunAsSubject(returned_subject) method to switch identity for the current thread.
这要求上下文切换到内核线程,以处理将数据移动到磁盘以及从磁盘移出数据的任务。
This requires a context switch to the kernel thread to handle the task of moving data to and from disk.
切换上下文的所有开销都一次性应用到线程。
All the overhead of switching contexts is applied to the thread one time.
由于任意工作量的一个线程或进程的上下文切换涉及到的开销较大,小粒度级的系统往往效率低下且遭遇低性能问题。
Due to the overhead involved in context switching to a thread or process for any amount of work, systems with small-scope granularity are often inefficient and suffer from low performance.
CPU上的每个处理器都拥有自己的CSA(当前保存区)指针,指向当线程或中断处理程序由于上下文切换而被中断或交换时使用的MST。
Each processor on the CPU has its own CSA (current save area) pointer that points to the MST that is to be used when a thread or interrupt handler is interrupted or swapped due to context switch.
事实上,太多的线程甚至会降低性能,因为它会导致额外的环境切换开销。
Indeed, too many threads will even degrade performance because of the additional context switching overhead.
有了微线程,我们就可能在目前中等性能的PC 机上运行数以万计的并行进程,还可以每秒钟几十万次地在上下文之间切换。
With microthreads, it is possible to run tens of thousands of parallel processes on a moderately capable modern PC, and to switch between contexts hundreds of thousands of times every second.
然而,我们必须小心,因为随着线程的增加,上下文切换也增加。
However, we had to be careful because, as you increase this number, context switching also increases.
这使得在一个线程编辑器会话中,您可以轻松地在两者之间切换。
This enables you to easily switch between the two within a single routine editor session.
若你切换线程到出错的线程,输入~将所有的线程列举出来,一个断点会标记有问题的线程。
If you switch threads and want to get back to the faulting thread, type ~ to list all threads and the faulting thread will be marked with a dot.
由于要在线程间进行上下文切换,因此CPU简直变成了超载。
The CPU simply becomes overburdened by context switching between threads.
另外,如果每个线程都忙于处理网络连接,线程之间的上下文切换会很频繁。
And if each thread (ergo network connection) is busy, then the context switching to each thread can be significant.
因为在单元测试中的并行任务通常很小同时也很少,在调度程序切换线程之前它们通常一直运行到结束,除非强迫它(也就是通过wait )。
Because concurrent tasks in unit tests are usually small and few, they usually run to completion before the scheduler switches the thread, unless it is forced to (say, by wait ).
线程上下文切换的代价并不大。
你现在可以在Debug视图中快速切换挂起线程
You can now quickly switch between suspended threads in the Debug view
而且,在这个比较慢的 366MHz芯片上可以在大约10秒内执行一百万次上下文切换(所涉及的线程数对耗时并无重大影响)。
Moreover, on this fairly slow 366 MHz chip, one million context switches can be performed in about 10 seconds (the number of threads involved is not particularly significant to the timing).
而且,在这个比较慢的 366MHz芯片上可以在大约10秒内执行一百万次上下文切换(所涉及的线程数对耗时并无重大影响)。
Moreover, on this fairly slow 366 MHz chip, one million context switches can be performed in about 10 seconds (the number of threads involved is not particularly significant to the timing).
应用推荐