- 論壇徽章:
- 0
|
![]()
3.6.1 Per-upcall event ordering 回調(diào)前的事件次序
The techniques described in the previous section for storing events separate the event types that pass TCBs from those that don't. This means that event ordering is not implicit, and would require extra work to preserve. However, it turns out that in most cases, order doesn't matter, and in the cases that it does matter, the UTS can always determine order.
前面的章節(jié)描述了存儲事件,區(qū)分事件類型的技術(shù)忽略了TCB來自那些禁止事項(xiàng)。這意味著事件的順序不是固定的,可能需要額外的工作去保護(hù)。但是在大多數(shù)情況下,順序沒關(guān)系,即使在順序有關(guān)系的情況下,UTS總能決定順序
As an example, suppose thread_block() and thread_unblock() events occur for the same Thread ID in the same upcall. In one interpretation, where the thread_block() event occurred first, the UTS last knew the corresponding thread to be running, so the two events simply mean that the thread can be continued. In the other interpretation, where the thread_unblock() event occurred first, the Thread ID has been recycled. However, this isn't possible, since there must have been an intervening thread_new() event, which couldn't have happened until after the Thread unblocked.
舉個(gè)例子,假設(shè)一個(gè)線程在一次回調(diào)是thread_block()和thread_unblock()事件都發(fā)生了。一種情況,如果thread_block()先發(fā)生,UTS最后知道通信的線程在運(yùn)行,所以兩個(gè)事件表示該線程可以繼續(xù)執(zhí)行。另一種情況,如果thread_unblock事件先發(fā)生,線程的ID可以被重新利用,但是,這不可能,因?yàn)樗欢ㄊ且粋(gè)在thread_new()事件之間,在一個(gè)線程被解鎖之前是不可能發(fā)生的。
3.7 Upcall parallelism 回調(diào)對應(yīng)
This section is not yet adequately fleshed out. Issues to consider:
這部分還有沒適當(dāng)?shù)某鋵?shí),關(guān)鍵要考慮
How do upcalls from multiple processors keep from stomping on each other? For example, if we have only one chain of TCBs, how does it get safely used?
怎么才能避免回調(diào)在多個(gè)處理器上跳來跳去,比如,如果只有一鏈TCB,怎么能讓它被安全的使用。
What if the UTS doesn't process the TCBs before another upcall happens? Do we run the risk of overflowing the TCB chain?
如果在新的回調(diào)發(fā)生時(shí),UTS不能處理TCB怎么辦,要運(yùn)行這個(gè)存在溢出危險(xiǎn)的TCB鏈嗎
* How do we handle races between the UTS and the kernel? For example, signals cannot be cleared until delivered to a thread, and the kernel must look at the userland bitmap to see if a signal is still pending.
怎么處理UTS和內(nèi)核間的競爭呢,比如,在信號傳遞給線程前不能被清空,那么內(nèi)核必須檢查用戶空間的位圖,去看是否信號還在傳遞中。
3.8 Kernel scheduler 內(nèi)核調(diào)度
The kernel scheduler needs a major overhaul in order to support KSEs. Support for the following features is necessary:
內(nèi)核調(diào)度需要進(jìn)行仔細(xì)檢查以便支持KSE,下面的特征是必須支持的
* Soft affinity. The scheduler should try to keep processes running on the same processors if there is the possibility of reaping benefits from increased cache locality.
軟親緣。調(diào)度程序應(yīng)該盡力保證一個(gè)進(jìn)程在被調(diào)度前后運(yùn)行在同一個(gè)CPU 上,這樣可以通過增加緩存的擊中率提高性能。
* Hard affinity (binding). Some programs may wish to bind a KSE (pedantically speaking, a KSEG is bound) to a particular processor in order to improve cache locality, or to tighten the bounds on a real-time task. Bound KSEs are run only on one CPU, unless priority inheritance forces it to be run on another CPU in order to avoid deadlock due to priority inversion.
硬親緣(綁定)。一些程序可能希望把KSE綁定在一個(gè)單獨(dú)的CPU上(準(zhǔn)確的說,KSEG)來提高緩存的擊中率,或是讓實(shí)時(shí)任務(wù)更嚴(yán)密,被綁定的KSE只運(yùn)行在一個(gè)CPU上,除非在優(yōu)先級倒置時(shí),為了避免死鎖,優(yōu)先級繼承迫使它運(yùn)行在另一個(gè)CPU上。
* Increased parallelism. The current scheduler can only be executed by one processor at a time, which makes it a severe bottleneck, depending on the type of system load.
對應(yīng)增長。在同一時(shí)刻內(nèi),調(diào)度程序只能運(yùn)行在一個(gè)處理器上,隨著系統(tǒng)的負(fù)載量增大,這產(chǎn)生了嚴(yán)重的瓶頸。
Part of the solution is to implement per-CPU scheduling queues. Each CPU has an associated queue for softly affined KSEs, as well as a queue for bound KSEs. In addition, there is a global queue for fixed-priority KSEs, such as interrupt threads and real-time KSEs. Fixed-priority KSEs prefer to run on the same CPU as the last time they were run, but scheduling issues keep more complex affinity algorithms from being beneficial for this class of KSEs. See Figure 9 for a simplistic representation of the various scheduling queues. The diagram ignores some details such as split queues for various priorities.
這個(gè)問題的解決方案是實(shí)現(xiàn)單CPU調(diào)度隊(duì)列。每個(gè)CPU有一個(gè)軟親緣KSE隊(duì)列和一個(gè)綁定KSE隊(duì)列。此外,還有一個(gè)為固定優(yōu)先級KSE設(shè)的全局隊(duì)列。比如中斷處理線程和實(shí)時(shí)KSE。確定優(yōu)先級的KSE更希望運(yùn)行在他們上次運(yùn)行的CPU上,但是調(diào)度算法有更多對這類KSE有益的負(fù)雜親緣算法。圖9顯示了一個(gè)十分簡單的各種調(diào)度隊(duì)列的代表。圖忽略了某些細(xì)節(jié),比如把隊(duì)列分成不同優(yōu)先級
Each CPU schedules from its own queues, and resorts to stealing runnable softly affined KSEs from other CPUs if there are no runnable KSEs. Every so often (exact number to be determined by benchmarking, but a likely number is 5 seconds), CPU loads are calculated, and if the loads are too disparate, the under-loaded CPU(s) steal additional KSEs from the overloaded CPU(s) in an attempt to balance the load. Instantaneous per-CPU load is defined as the number of runnable timesharing KSEs in a CPU's queues. Instantaneous system load is the sum of the instantaneous per-CPU loads. Note that normal (non-balancing) KSE stealing is adequate to keep the system busy if there is enough work to do, but that without periodic load balancing, time sharing becomes unfair if there aren't approximately equal CPU loads.
每個(gè)CPU在自己的隊(duì)列中進(jìn)行調(diào)度,如果沒有可運(yùn)行的KSE,則從其他CPU那里取一些有軟親緣的KSE,并且重新排序。每過一段時(shí)間(確切得數(shù)子通過測試決定,但是可能的是5秒)會計(jì)算CPU負(fù)載,如果CPU之間的負(fù)載差別很大低負(fù)載的CPU從高負(fù)載CPU的調(diào)度隊(duì)列里取一些KSE加入自己的隊(duì)列,以達(dá)到負(fù)載平衡。瞬間單CPU負(fù)載定義為在當(dāng)前CPU的隊(duì)列里,可運(yùn)行的分時(shí)KSE的數(shù)量。瞬間系統(tǒng)負(fù)載是瞬間單CPU負(fù)載的和。注意,正常的KSE獲取是適量的,為了保證在有足夠工作時(shí),系統(tǒng)的繁忙。如果不進(jìn)行周期性的負(fù)載平衡,如果沒有大致均衡的CPU負(fù)載,分時(shí)就會變得不公平。
This is essentially the approach that was taken in DEC OSF/1 3.0 [Denham], and it seems to have worked well there. One notable difference between our kernel and OSF/1 is that our interrupts are backed by threads, whereas OSF/1 keeps spl()s (IPLs in their terminology). However, this doesn't affect the design, since OSF/1 already has to handle real-time scheduling.
這個(gè)在本質(zhì)上和DEC 的OSF/1.3.0相似,這種方法在OSF上好象很有效,一個(gè)值得注意的不同是,我們的中斷是基于線程的,雖然OSF/1擁有spl,但是,這個(gè)沒有影響設(shè)計(jì),因?yàn)镺SF/1必須處理實(shí)時(shí)調(diào)度。
Figure 9: Kernel scheduler queues 內(nèi)核調(diào)度隊(duì)列
![]()
4 Summary
Discussion about improved threads support in FreeBSD has been ongoing for several years. The KSE project aims to implement a kernel mechanism that allows the kernel and userland to support threaded processes and communicate with each other effectively so that the necessary information is available for both to do their jobs efficiently and correctly.
討論在FreeBSD中增加線程支持已經(jīng)進(jìn)行了幾年。KSE項(xiàng)目的目標(biāo)是實(shí)現(xiàn)一個(gè)內(nèi)核結(jié)構(gòu),允許內(nèi)核和用戶空間支持線程處理以及相互間有效的通信以便它們有效和正確的完成工作所必要的信息對兩者來說都是可用的。
Glossary
KSE:
Kernel-scheduled entity. This gets scheduled.
Thread:
A runnable context. This gets suspended.
KSEG:
Kernel-scheduled entity group.
PCB:
Process control block.
SA:
Scheduler activation.
TCB:
Thread control block.
UTS:
Userland threads scheduler. Userland, multi-level, and scheduler activation-based threads libraries all have a UTS.
Bibliography
Anderson
Thomas E. Anderson, Brian N. Bershad, Edward D. Lazowska, and Henry M. Levy, Scheduler Activations: Effective Kernel Support for the User-Level Management of Parallelism, ACM Transactions on Computer Systems, Vol. 10, No. 1, February 1992, Pages 53-79.
Boykin
Joseph Boykin, David Kirschen, Alan Langerman, and Susan LoVerso, Programming under Mach, Addison-Wesley Publishing Company, Inc. (1993).
Butenhof
David R. Butenhof, Programming with POSIX threads, Addison Wesley Longman, Inc. (1997).
Denham
Jeffrey M. Denham, Paula Long, and James A. Woodward, DEC OSF/1 Symmetric Multiprocessing, Digital Technical Journal, Vol. 6, No. 3.
Kleiman
Steve Kleiman, Devang Shah, and Bart Smaalders, Programming with Threads, SunSoft Press (1996).
Lemon
Jonathan Lemon, Kqueue: A generic and scalable event notification facility, BSDcon Conference Proceedings (2000), http://people.freebsd.org/~jlemon/kqueue.pdf.
Mauro
Jim Mauro and Richard McDougall, Solaris Internals, Sun Microsystems Press (2001).
McKusick
Marshall Kirk McKusick, Keith Bostic, Michael J. Karels, and John S. Quarterman, The Design and Implementation of the 4.4BSD Operating System, Addison-Wesley Publishing Company, Inc. (1996).
Vahalia
Uresh Vahalia, UNIX $^{TM}$ Internals: The New Frontiers, Prentice-Hall, Inc. (1996).
About this document ...
Kernel-Scheduled Entities for FreeBSD
This document was generated using the LaTeX2HTML translator Version 2002-2-1 (1.70)
Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -split 0 -dir html -no_navigation -no_white -show_section_numbers freebsd_kse.tex
The translation was initiated by Chris Knight on 2003-01-01
Chris Knight 2003-01-01
[ 本帖最后由 DarkBlueSea 于 2006-4-10 13:11 編輯 ] |
|