日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > 綜合技術 > xenomai-GNU/Linux上的RTOS模擬架構實現

xenomai-GNU/Linux上的RTOS模擬架構實現

來源:程序員人生   發布時間:2016-06-03 08:42:33 閱讀次數:2795次

Xenomai - Implementing aRTOS emulation

framework on GNU/Linux

xenomai-GNU/Linux上的RTOS摹擬架構實現

PhilippeGerum

FirstEdition

Copyright? 2004

Copyright ? 2002Philippe Gerum

Permission is granted to copy, distribute and/or modify thisdocument under the terms of the GNU Free Documentation License, Version 1.2 orany later version published by the Free Software Foundation; with no InvariantSections, no FrontCover Texts, and no Back-Cover Texts. A copy of the licenseis published on gnu.org: "GNU FreeDocumentation License" [http://www.gnu.org/licenses/fdl.html].

April2004

Abstract

Generally speaking, the Xenomai technology first aims at helpingapplication designers relying on traditional RTOS to move as smoothly aspossible to a GNU/ Linux-based execution environment, without having to rewritetheir application entirely.

This paper discusses the motivations for proposing this framework,the general observations concerning the traditional RTOS directing thistechnology, and some in-depth details about its implementation.

The Xenomai project has been launched in August 2001. It has mergedin 2003 with theRTAI project[http://www.gna.org/projects/rtai/]to produce an industrialgrade real-time Free Software platform for GNU/Linuxcalled RTAI/fusion, on top of Xenomai's abstract RTOS core. Eventually, theRTAI/fusion effort became independent from RTAI in 2005 as thexenomai project [http://www.gna.org/projects/xenomai/].

Linux is a registered trademark ofLinus Torvalds. Other trademarks cited in this paper are the property of theirrespective owner.


Table of Contents

1.  White paper.................................................................................................2

1.1.  Introduction.......................................................................................2

1.2.  Porting traditional RTOS-basedapplications to GNU/Linux ........................ 3

1.3.  A common emulation framework.......................................................... 7

1.4.  Nucleus description........................................................................... 10

1 . White paper

1.1 . Introduction

A simpler migration path from traditionalRTOS to GNU/Linux can favour a wider acceptance of the latter as a real-timeembedded platform. Providing emulators to mimic the traditional RTOS APIs isone of the initiative the free software community can take to fill the gapbetween the very fragmented traditional RTOS world and the GNU/Linux world, inorder for the application designers relying on traditional RTOS to move assmoothly as possible to the GNU/

把傳統的RTOS移植到GNU/Linux,使linux成為1個實時嵌入式系統,是被廣泛接受的。它提供了類傳統的RTOS接口,本身這就是自由軟件組織推重的精神所在,這消除各個分類的傳統RTOS和LINUX世界之間的隔閡,為了那些在傳統RTOS世界里工作的利用設計者提供了1種平滑過渡的方式。

There is a lack of common softwareframework for developing these emulators, whereas the behavioural similaritiesbetween the traditional RTOS are obvious.

在開發這些摹擬接口的是缺少1個通用的軟件架構,然后傳統的RTOS之間的行動的相似性是明顯的存在的。(譯者注:行動相似性,即讀、寫、調度上的實現原理差不多,不過是代碼差異而已

The Xenomai technology aims at fulfillingthis gap, by providing a consistent architecture neutral and generic emulationlayer taking advantage of these similarities. It is also committed to providean increasing set of traditional RTOS emulators built on top of this layer.

Xenomai志在消除這類隔閡,通過提供1致性的架構中間層和1般性的摹擬接口層,有效利用了這類相似性。建立在中間層之上的,固然也需要提供1種延續增長的傳統RTOS仿真者的接口集合。

Xenomai relies on the common features andbehaviours found between many embedded traditional RTOS, especially from thethread scheduling and synchronization standpoints. These similarities areexploited to implement a nucleus exporting a set of generic services. Theseservices grouped in a high-level interface can be used in turn to implementemulation modules of real-time application programming interfaces, which mimicthe corresponding real-time kernel APIs.

Xenomai依賴于發現不同RTOS之間的共性,特別從線程調度和同步方面。通過利用這類相似性構建出1個微內核輸出1系列的1般服務接口。在更高水平的接口可以利用這些服務,反過來即實現了實時的利用的編程接口的摹擬實現,即最小化相應的實時內核API。

A similar approach was used for the CarbonKernel [http://savannah.gnu.org/projects/carbonkernel/] project [1]in the simulation field, in which RTOS simulation models are built on top of ageneric virtual RTOS based on event-driven techniques.

1.2 . Porting traditional RTOS-based applications toGNU/Linux(移植)

The idea of using GNU/Linux as an embeddedsystem with real-time capabilities is not novel. The reader can refer to JerryEpplin's article in the October 97 issue of Embedded Systems Programming for adiscussion about GNU/Linux potential in the embedded field [2].

把GNU/Linux當作1個嵌入式實時系統不是天方夜譚。讀者可以參考JerryEpplin的97年10月份發表的關于GNU/Linux在嵌入式領域的嵌入式系統編程的討論。

Throughout this document, we will use theexpression source RTOS to indicatethe traditional real-time operating from which the application is to be ported,andtarget OS to indicate GNU/Linuxor any other free operating system to which the application could be ported.

1.2.1 . Limited high-level code modification(有限的高層代碼修改)

Keeping the initial design andimplementation of a hard real-time application when attempting to port it toanother architecture is obviously of the greatest interest.Reliability andperformance may have been obtained after a long, complex and costly engineeringprocess,one does not want to compromise. Consequently, the best situation is to have the closest possibleequivalence between the source and destination RTOS programming interfaces, asfar as both the syntax and the semantics are concerned.

移植RTOS到其他架構代碼中最感興趣的部份,必定是保持初始化的設計和硬實時利用的實現。可靠性和運行性能需要經歷1個長時間、復雜和消耗的工程設計進程才能得出結果,固然這部份可能不想去讓步。因此,最好的情形,在源與目的的RTOS變成接口間建立最可能的同等性,盡可能把語法和語義斟酌在內。

An illustration of this can be taken fromthe support of a priority inheritance protocol [3]  by the mutual exclusion services. Theseservices allow concurrent threads to protect themselves from race conditionsthat could occur into critical sections of code. The purpose of this discussionis not to argue whether relying on priority inheritance for resolving priorityinversion problems is a major design flaw or a necessary safety belt for areal-time application, but only to emphasize that any cases, if this feature isused in the source RTOS, but not available from the target OS, the resourcemanagement strategy must be reevaluated for the application, since priorityinversion risks will exists.

這部份的解釋,可參考互斥服務中的優先級繼承的實現支持。服務允許當前線程保護自己的臨界代碼部份不受其他部份的干擾。固然這個討論的重點不是說是不是依賴于優先級繼承來解決優先級反轉,而是1個在實時利用系統的1個主流的設計和必須的安全保護。但僅僅強調的任意情況下,如果這類特性被用在源RTOS,而沒有在目標OS中存在,那末源OS的管理策略必須根據利用被重新評估,雖然優先級的反轉的危險依然存在。

1.2.2 . RTOS behavioural compatibility

During the past years, major embedded RTOS,such as VRTX, VxWorks, pSOS+ and a few others, have implemented a real-timekernel behaviour which has become a defacto standard, notably for threadscheduling, inter-thread synchronization, and asynchronous event management. Toillustrate this, let us talk about a specific concern in the interrupt servicemanagement.

在過去1段時間,主流的RTOS,比如VRTX,VxWorks,pSOS+等,已實現了實時內核的行動標準,主要體現在線程調度,內部線程同步,和事件的異步管理。為了說明這個問題,我們可以先就中斷服務管理中斷管理中的耽憂來具體說明。

A well-known behaviour of such RTOS is tolock the rescheduling procedure until the outer interrupt service routine (orISR) - called first upon possibly nested interrupts - has exited, after which aglobal rescheduling is finally stated. This way, an interrupt service routinecan always assume that no synchronous thread activity may run until it hasexited. Moreover, all changes impacting the scheduling order of threads, due toactions taken by any number of nested ISRs (e.g. signaling a synchronizationobject on which one or more threads are pending) are considered once andconjunctively, instead of disjunctively.

1個廣為人知的RTOS使用的方法即,鎖住重新調度進程,直至ISR履行退出(第1個被嵌套的中斷)。以后才允許進行再調度進程。這類方法,即ISR運行時,總是假定沒有同步線程被激活運行,直至ISR退出。更多的是,由于斟酌到嵌套中斷的ISR運行的1次性和組合性,其動作帶來的改變,會影響側重新調度線程的順序,

For instance, if a suspended thread isfirst resumed by an ISR, then forcibly suspended later by another part of thesame ISR, the outcome will be that the thread will not run, and remainsuspended after the ISR has exited. In the other hand, if the RTOS sees ISRs asnon-specific code that can be preempted by threads, the considered thread willbe given the opportunity to execute immediately after it is resumed, until itis suspended anew. Obviously, the respective resulting situations won't beidentical.

例如,如果1個懸掛的線程被ISR恢復,然后又被該ISR的另外1部份代碼強迫suspend,終究的輸出可能就是這個線程不是可運行的,同時會保持suspend直至該ISR退出。換句話說,如果RTOS,把ISR看作1段具體的可以被線程搶占的代碼,相應的線程可能就會在被恢復時,立即去履行,直至被重新suspend。明顯,相應的結果可能其實不是相同的。

1.2.3 . Reevaluation of the real-time constraints

Making GNU/Linux a hard real-time system iscurrently achieved by using a co-kernel approach which takes control of thehardware interrupt management, and allows running real-time tasks seamlesslyaside of the hosting GNU/Linux system [4]. The 'regular' Linux kernel iseventually seen as a low-priority, background of the small real-time executive.TheRTLinux [http://www.rtlinux.org]project is representative of this technical path. However, this approach has amajor drawback when it comes to port complex applications from a foreignsoftware platform: since the real-time tasks run outside the Linux kernelcontrol, the GNU/Linux programming model cannot be preserved when porting theseapplications. The result is an increased complexity in redesigning anddebugging the ported code.

使GNU/LINUX成為1個實時操作系統,可以通過1個協內核的方法實現,它可以接收硬件中斷的管理,同時允許實時任務允許在宿主GNU/LINUX系統中。傳統的linuxkernel被看作1個低優先級任務,作為1個實時內核的后臺任務履行。RTlinux就是此種技術的代表。但是,這類方法有1個主要的問題,就是移植1個復雜的利用。雖然實時任務允許在linuxkernel以外,不受linuxkernel的控制,但是其實不影響GNU/Linux在移植利用時的編程模型的的實現。結果就是,調試和設計移植代碼的復雜度增加了。

In some cases, choosing a traditional RTOSto run an embedded application has been initially dictated by the memoryconstraints imposed by the target hardware, instead of actual realtimeconstraints imposed by the application itself. Since embedded devices tend toexhibit ever increasing memory and processing horsepower, it seems judicious toreevaluate the need for real-time guarantee when considering the porting effortto GNU/Linux on a new target hardware. This way, the best underlying softwarearchitecture can be selected. In this respect, the following, the followingcriteria need to be considered:

有些情況下,選擇的1個傳統RTOS運行1個嵌入式的利用,被簡單的口述為,被目標硬件的內存束縛,而不是被利用本身的實時性束縛。雖然,嵌入式裝備的趨勢是更大的內存和更高的功率,重新評估實時性是非常明智的,以保證移植到GNU/Linux到目標平臺的影響降到最低。依照這類方式,選擇最優的軟件架構。1方面,接下來的情形也需要被斟酌:

?   Determinism and criticality.

What is theworst case interrupt and dispatch latencies needed ?

最壞情形下的中斷履行延遲?

Does a misseddeadline lead to a catastrophic failure ?

中斷的丟失是不是會致使災害性的后果?

?   Programming model

What is theoverall application complexity, provided that the higher the complexity, thegreater the need for powerful debugging aid and monitoring tools.

?   Is there a need need forlow-level hardware control ?

?   是不是需要1個低級的硬件控制?

Is the real-timeactivity coupled to non real-time services, such as GUI or databases, requiringsophisticated communications with the non real-time world ?

實時的代碼耦合到非實時的服務中,比如GUI或數據庫,是不是要求復雜的通訊?

1.2.4 . Some existing solutions

In order to get whether hard or softreal-time support, several GNU/Linux-based solutions exist [5][6]. It is notthe purpose of this paper to present them all exhaustively. We will onlyconsider a two fold approach based on free software solutions which is likelyto be suited for many porting taskings, depending on the actual real-timeconstraints imposed by the application.

1.2.4.1 . Partial rewriting using a real-time GNU/Linuxextension

Real-timeenabling GNU/Linux using RTAI. Strictly speakingLinux/RTAI [7] is not a real-time operating system but rather a real-time Linuxkernel extension, which allows running real-time tasks seamlessly aside of thehosting GNU/Linux system. The RTAI cokernel shares hardware interrupts andsystem-originated events like traps and faults with the Linux kernel using theAdeos [http://www.adeos.org/]virtualization layer, which in turn ensures RTAI low interrupt latencies. Thenative RTAI API provides the applications a wealth of useful services,including counting semaphores, POSIX 1003.1⑴996 facilities such as pthreads,mutexes and condition variables, also adding remote procedure call facility, mailboxes,and precision timers. Most services are symmetrically available from kernelmodule and user-space programs.

利用RTAI使能GNU/Linux的實時性。嚴格的說,RTAI其實不是1個實時性OS,僅僅是作為linuxkernel的實時性擴大,允許以任務的狀態與LinuxKernel運行到達實時性的目的。RTAI協內核同享硬件中斷和利用adeos虛擬層觸發的毛病和圈套事件,反過來講這樣能保證RTAI最低的中斷延遲。原始的RTAIapi提供給利用大量的有效的服務,包括計數信號量,POSIX1003.1⑴996的兼容性,比如支持pthread,mutex和條件變量,一樣增加了遠程調用兼容性,郵箱,和精確的timer。大多數的服務都是可以從內核模塊和用戶空間取得。

RTAI 2.x and 3.x provide a means to executehard real-time tasks in user-space context (x86 only), but still outside theLinux kernel control, which is best described as running 'user-space kernelmodules'. This feature, namely LXRT, is a major step toward a simpler migrationpath from traditional RTOS, since programming errors occuring within real-timetasks don't jeopardize the overall GNU/Linux system sanity, at the expense of afew microseconds more latency.

RTAI 2.X 和3.x版本提供1種用戶空間內上下文的硬實時任務機制,但是依然是脫離linux內核的控制,最貼切的描寫為’用戶空間內內核模塊’。這類特點,美其名曰:LXRT,是在進行從傳統RTOS移植進程中的主要步驟,且實時任務的代碼編程毛病其實不影響linux系統的完全性,但需要消耗1部份微秒級的延遲時間。

Adhoc services emulation. A first approach consistsin emulating each real-time facility needed by the application using acombination of the RTAI services. An ad hoc wrapping interface has to bewritten to support the needed function calls. The benefit of the wrappingapproach lies in the limited modifications made to the original code. However,some RTAI behaviours may not be compliant with the source operating system's.For the very same reason, conflicts between the emulated and native RTAIservices may occur in some way.

Ad hoc 服務仿真。第1種方法由每個實時裝備根據利用所需的,同時利用RTAI服務來實現仿真。Adhoc封裝接口必須支持所需的函數調用。封裝的好處在于,在1個有限的范圍內進行原始代碼的修改。但是,1些RTAI的行動可能其實不是與源操作系統匹配。基于許多緣由,存在許多方式在仿真與原始RTAI服務的之間的沖突可能會產生。

Complete port to RTAI. A second approach consists in fully porting the application overthe native RTAI API. In such a case, RTAI facilities are globally substitutedfrom the facilities from the source RTOS. This solution brings improvedconsistency at the expense of a possible large-scale rewriting of theapplication, due to some fundamental behavioural differences that may existbetween the traditional RTOS and the native RTAI interface.

RTAI的代碼移植。第2種方法講述的是移植利用到原始的RTAIAPI。在這類情況下,RTAI裝備是被源RTOS所替換。這類方案會帶來1致性的增加,由于在傳統的RTOS和原始RTAI接口上的基本的差異性存在,將會以損失更高的利用代碼的重寫為代價。

1.2.4.2 . Unconstrained user-space emulations

A few traditional RTOS emulators exists inthe free software world. There are generally designed on top of the GNU/LinuxPOSIX 1003.1⑴996 layer, and allow to emulate the source RTOS API in auser-space execution context, under the control of the Linux kernel.

在自由軟件世界,存在1小部份的傳統的RTOS摹擬器。他們被設計在運行在GNU/Linux的 POSIX層之上,允許用戶接口的RTOS API,并且受linuxkernel的控制。

Once one of the most proeminent effort inthis area used to be the Legacy2linux project [8]. This project, sponsored byMontavista Software, aimed at providing ["a series of Linux-residentemulators for various legacy RTOS kernels."] Just like Xenomai, [ theseemulators are designed to ease the task of porting legacy RTOS code to anembedded Linux environment".] Two emulators have been made available bythis project, respectively mimicking the APIs of WindRiver's pSOS+ and VxWorksreal-time operating systems. However, this project has stalled due to a lack ofmaintenance and contribution.

曾,這個領域里最突出的1個項目Legacy2linux。這個項目,由MontavistaSoftware援助,旨在提供類xenomai。通過這個項目可以取得兩個仿真器,1個是模仿了WindRiver的 pSOS+,另外1個是仿的VxWorks實時操作系統。但是,由于保護性和援助方面的缺少這個項目已落伍了。

The benefits of this approach is mainly tokeep the development process in the GNU/ Linux user-space environment, insteadof moving to a rather 'hostile' kernel/supervisor mode context. This way, therich set of existing tools such as debuggers, code profilers, and monitorsusable in this context are immediatly available to the application developer. Moreover, the standard GNU/Linux programming model is preserved,allowing the application to use the full set of of facilities existing in theuser space (e.g. full POSIX support, including inter-process communication).Last but not least, programming errors occuring in this context don'tjeopardize the overall GNU/Linux system stability, unlike what can happen if abug is encountered on behalf of a hard real-time RTAI task which could causeserious damages to the running Linux kernel.

這個方法的有事在于開發了GNU/LINUX的用戶空間的進程上下文,而不是在1個“hostfile”的內核超級模式的上下文。這類方式,借助已存在的豐富的工具,比如調試器、代碼配置器和監視器,利用開發者可以輕易的獲得。更多的,標準的linux編程模式是保存的,允許利用利用完全的用戶空間的工具(完全的POSIX支持,包括進程內通訊)。固然最后的不代表是最不重要的,產生在上下文的編程毛病,不會影響整體的系統的穩定性,不像產生在硬實時RTAI系統任務中的毛病,會致使運行中的linuxkernel產生嚴重的破壞。

However, we can see at least three problemsin using these emulators, depending on the application constraints:

依賴利用,我們最少可以看到3個問題:

?    First, the emulated API they provide is usually incomplete for aneasy port from the source RTOS. In other words, only a limited syntacticcompatibility is available.

?    首先,被摹擬的接口常常是不完全的從源RTOS的輕量型移植。換句話說,就是只有有限的語法兼容性。

?    Second, the exact behaviour of the source RTOS is not reproduced forall the functional areas. In other words, the semantic compatibility might notbe guaranteed.

?    第2,源RTOS的準確的具體表示其實不會在所有調用途重現。換句話說,語義的兼容性是不能被保證的。(譯者注:太監在某些情境下的功能是不完全的

?   These emulators don't share anycommon code base for implementing the fundamental real-time behaviours, even soboth pSOS+ and VxWorks share most of them.The resulting situation leads to redundant implementation efforts, without anybenefit one can see in code mutualization.

?    第3,那些摹擬的實現,在實現基本的實時行動,不會同享任何相同的基礎代碼,即使如此pSOS+和VxWorks之間還是同享了大部份代碼。這類情形的結果就是大媽冗余問題,在代碼的互助性來講看不到任何好處。

?    And finally, even combined to the latest Linux 2.6 features likefine-grain kernel preemption and low latency efforts, these emulators cannotdeliver deterministic real-time performance.

?    最后,結合最新的linux2.6內核的搶占和低延遲影響,這些摹擬器在實時性能上沒有起到決定性的作用。

1.3 . A common emulation framework

1.3.1 . Common traditional RTOS behaviours

In order to build a generic and versatileframework for emulating traditional RTOS, we chose to concentrate on a set ofcommon behaviours they all exhibit. A limited set of specific RTOS featureswhich are not so common, but would be more efficiently implemented into thenucleus than into the emulators, has also been retained. The basic behavioursselected cover four distinct fields:

為了仿真傳統的RTOS建立通用的架構,我們選擇集中在所看到的通用的具體行動。具體RTOS的特點是有限的,其實不會1那末1般通用,但是相對模仿來講會更有效的實現到微內核中去,因此會被保存。基本行動的選擇覆蓋了4個不同的領域。

1.3.1.1 . Multi-threading

Multi-threading provides the fundamentalmechanism for an application to control and react to multiple, discrete externalevents. The nucleus provides the basic multi-threading environment.

多線程,為那些多重的分散的外部事件做集中控制,提供了1種基礎機制。微內核提供了基本的多線程環境

Threadstates. The nucleus has to maintain the currentstate of each thread in the system. A state transition from one state toanother may occur as the result of specific nucleus services called by the RTOSemulator. The fundamental thread states defined by the nucleus are:

線程狀態。微內核必須保持系統的每一個線程確當前狀態。RTOS仿真器調用具體的微內核服務,會致使狀態從這個狀態到另外1個狀態的轉化。基本的線程狀態定義以下:

?    DORMANT and SUSPENDED states are cumulative, meaning that the newlycreated thread will still remain in a suspended state after being resumed fromthe DORMANT state.

?    DORMANT 和 SUSPENDED狀態是累計的,意味著新創建的線程在從DORMANT恢復后依然保存在1個suspended的狀態。

?    PENDING and SUSPENDED states are cumulative too, meaning that athread can be forcibly suspended by another thread or service routine whilepending on a synchronization resource (e.g. semaphore, message queue). In sucha case, the resource is dispatched to it, but it remains suspended untilexplicitly resumed by the proper nucleus service.

?    PENDING 和SUSPENDED也是1樣,意味著,1個線程在懸停1個同步資源時,可以被另外1個線程強迫suspend,或另外1個服務程序suspend。在在這類情況下,資源被取得后,依然保存suspend狀態,直到適合的微內核服務將其喚醒。

?    PENDING and DELAYED states may be combined to express a timed waiton a resource. In such a case, the time the thread can be blocked is bound to alimit enforced by a watchdog.

?    PENDING 和DELAYED狀態組合起來,多是表達1個對資源的時間上的等待。在這類情況下,線程會阻塞,會被1個看門狗限定到1個有限的時間內。

Schedulingpolicies. By default, threads are scheduledaccording to a fixed priority value, using a preemptive algorithm. There isalso a support for round-robin scheduling among a group of threads having thesame priority, allowing them to run during a given time slice, in rotation.Moreover, each thread undergoing the round-robin scheduling is given anindividual time quantum.

調度機制。默許的,線程的調度依照固定的優先級,利用了1個搶占邏輯。在具有相同優先級的1組線程中也是適用的,允許他們在給定的時間片內運行。更多的是,每一個線程的輪轉調度是分別獨立的時間片。

Prioritymanagement. It is possible to use either anincreasing or decreasing thread priority ordering, depending on an initialconfiguration. In other words, numerically higher priority values could eitherrepresent higher or lower scheduling priorities depending on the configurationchosen. This feature is motivated by the existence of this two possibleordering among traditional RTOS. For instance, VxWorks, VRTX, ThreadX and ChorusO/S use a reversed priority management scheme, where the higher the value, thelower the priority. pSOS+ instead uses the opposite ordering, in which thehigher the value, the higher the priority.

優先級管理。依賴于初始化的配置,增加或下降線程的優先級是允許的。換句話說,數字化的更高的優先級可以代表更高調度權限或更低調度權限,依賴于選擇的配置。在傳統的RTOS,這類特點是可以激活的。例如,VxWorks,VRTX,ThreadX和ChorusO/S 用到了反轉優先級管理機制,數值越大優先級越低。pSOS+反而利用相反的順序,數值越大,優先級越高。

Runningthread. At any given time, the highest prioritythread which has been ready to run for the longest time among the currently runnablethreads (i.e. not currently blocked by any delay or resource wait) is electedto run by the scheduler.

運行中的線程。任何給定的時間,在當前可運行線程中,最高優先級的線程的可運行時間,完全有調度器決定的。

Preemption. When preempted by a higher priority thread, the running thread isput at the front of the ready thread queue waiting for the processor resource,provided it has not been suspended or blocked in any way. Thus it is expectedto regain the processor resource as soon as no other higher priority activity(i.e. a thread having a higher priority level, or an interrupt service routine)is eligible for running.

搶占。當被1個更高優先級線程搶占,運行中的線程被放置到ready 隊列頭,等待處理器資源,它也沒有被suspended或阻塞。因此在沒有任何更高優先級要求運行之前,它期望重新獲得處理器資源。

Manualround-robin. As a side-effect of attempting toresume an already runnable thread or the running thread itself, this thread ismoved at the end of its priority group in the ready thread queue. Thisoperation is functionally equivalent to a manual round-robin scheduling.

人為的輪轉。類似嘗試恢復1個準備好的可運行的線程或正在運行的線程本身的副作用,這個線程被移動都優先級組的ready隊列的末尾。這個操作同等于手動的進行循環調度。

Even if they are not as widespread as thoseabove in traditional RTOS, the following features are also retained for thesake of efficiency in the implementation of some emulators:

即使沒有和上面列出的傳統RTOS那樣傳播廣泛,為了1些仿真器在實現效力的斟酌,接下來的特點也是被保存的。

Priorityinversion. In order to provide support forpreventing priority inversion when using inter-thread synchronization services,the priority inheritance protocol is supported.

優先級反轉。當利用內部線程的同步服務,為了支持禁止優先級反轉,優先級繼承的協議是支持的。

Signaling. A support for sending signals to threads and running asynchronousservice routines to process them is available. The asynchronous service routineis run on behalf of the signaled thread context the next time it returns fromthe nucleus level of execution, as soon as one or more signals are pending.

信號。對進程來講,發送信號和運行異步的服務例程是可取得的。異步服務例程的運行,代表了信號線程的上下文切換,1旦1個或多個信號處于pending,下1次它從內核級的履行進程返回

Disjunctivewait. A thread is able to wait in a disjunctivemanner on multiple resources. The nucleus unblocks the thread when at least oneof the pending resources is available.

分離等待。1個線程能夠以分離的方式等待多重資源。當最少1個pending的資源可獲得時,微內核將線程設置為非阻塞。

1.3.1.2 . Thread synchronization

Traditional RTOS provide a large spectrumof inter-thread communication facilities involving thread synchronization, suchas semaphores, message queues, event flags or mailboxes.Lookingat them closely, we can define the characteristics of a basic mechanism whichwill be usable in turn to build these facilities.

傳統的RTOS提供了許多線程間的同步方式,包括信號量、消息隊列、標志或郵箱。仔細視察,我們可以定義1個基本的可用的建立這些裝備的機制。

Pending mode. The thread synchronization facility provides a means for threads topend either by priority or FIFO ordering. Multiple threads should be able topend on a single resource.

Pending模式。線程同步裝備提供1些方法要末通過優先級要末通過FIFO序列。多線程可以同時pend同1個資源

Priorityinheritance protocol. In order to prevent priorityinversion problems, the thread synchronization facility implements a priorityinheritance protocol in conjunction with the thread scheduler. Theimplementation allows for supporting the priority ceiling protocol as a derivativeof the priority inheritance protocol.

優先級繼承。為了禁止優先級反轉的問題,線程同步裝備結合線程調度器,實現了1個優先級繼承的協議。實現機制允許支持優先級的上限協議,作為1個優先級繼承的衍生品。

Time-boundedwait. The thread synchronization facility providesa means to limit the time a thread waits for a given resource using a watchdog.

時間等待有限性。線程同步裝備提供了1種方法限制線程的等待時間,利用本身的watchdog,為了所謂的資源進行等待。

Forcibledeletion. It is legal to destroy a resource whilethreads are pending on it. This action resumes all waiters atomically.

強迫刪除。當線程在pend資源的時候燒毀資源是合法的,這個動作自動會喚醒所有的等待者。

1.3.1.3 . Interrupt management

Since the handling ofinterrupts is one of the least well defined areas in RTOS design,the nucleus focuses on providing a simple mechanism with sufficienthooks for specific implementations to be built onto according to the emulatedRTOS flavour.

由于中斷的處理進程,在RTOS設計中是最不好定義的進程之1,微內核集中提供1種簡單的機制,依照摹擬的RTOS特點,建立具體的實現高效的回調機制。

Nesting. Interrupt management code is reentrant in order to supportinterrupt nesting safely.

嵌套:為了支持中斷嵌套,中斷管理代碼是可重入的。

Atomicity. Interrupts are associated with dedicated service routines calledISRs. In order for these routines not to be preempted by thread execution, therescheduling procedure is locked until the outer ISR has exited (i.e. in caseof nested interrupts).

原子性:中斷就是中斷服務子程序,被稱作ISR。為了服務子程序不被線程搶占,重調度的進程在ISR退出之前1直保持被鎖狀態。

Priority. ISRs are always considered as priority over thread execution.Interrupt prioritization is left to the underlying hardware.

優先級:ISR的優先級總是認為比線程優先級高。中斷的優先級低于頂層硬件。

1.3.1.4 . Time management

Traditional RTOS usually represent time inunits of ticks. These are clock-specific time units and are usually the periodof the hardware timer interrupt, or a multiple thereof. Since it needs tosupport both periodic and aperiodic time sources, the nucleus transparentlyswitches from periodic jiffies to time-stamp counter values depending on thecurrent timer operating mode.

 

Softwaretimer support. A watchdog facility is provided tomanage time-bound operations by the nucleus.

Absoluteand relative clock. The nucleus keeps a globalclock value which can be set by the RTOS emulator as being the system-definedepoch.

Some RTOS like pSOS+ also provide supportfor date-based timing, but conversion of ticks into conventional time and dateunits is an uncommon need that should be taken in charge by the RTOS emulatoritself.

1.3.2 . An architecture-neutral abstraction layer

After having selected the basic behaviours shared by traditionalRTOS, we have implemented them in a nucleus exporting a few service classes.These generic services will then serve as a founding layer for developing eachemulated RTOS API, according to their own flavour and semantics.

In order for this layer to be architectureneutral, the needed support for hardware control and real-time capabilitieswill be obtained from an underlying host software architecture, through arather simple standardized interface. Thus, porting the nucleus to a newrealtime architecture will solely consist in implementing this low-levelinterface for the target platform.

1.3.3 . Real-time capabilities

The host software architecture is expected to provide the primaryreal-time capabilities to the RTOS abstraction layer. Basically, the hostreal-time layer must handle at least the following tasks:

?    On request start/stop dispatching the external interrupts to aspecialized handler ;

?    Provide a means to mask and unmask interrupts ;

?    Provide a means to create new threads of control in their simplestform ;

?    Provide support for periodic and aperiodic interrupt sources used intimer management ;

?    Provide support for allocating chunks of non-pageable memory.

1.3.4 . Benefits

Xenomai aims at helping applicationdesigners relying on traditional RTOS to move as smoothly as possible to aGNU/Linux-based execution environment, without having to rewrite theirapplications entirely. Aside of the advantages of using GNU/Linux as anembedded system, the benefits expected from the described approach is mainly areduced complexity in designing new RTOS emulations. The architecture-neutralabstraction layer provides the foundation for developing accurate emulations oftraditional RTOS API, saving the burden of repeatedly implementing theirfundamental real-time behaviours. Since the abstraction layer also favours codesharing and mutualization, we can expect the RTOS emulations to take advantageof them in terms of code stability and reliability.

1.4 . Nucleus description

RTOS emulations are software modules whichconnect to the nucleus through the pod abstraction. The pod is responsible forthe critical housekeeping chores, and the real-time scheduling of threads.

RTOS仿真器是軟件模塊,它通過1個pod抽象鏈接到微內核。Pod代表了關鍵的保護工作,和線程的實時調度。

1.4.1 . Multi-threading support

The nucleus provides thread object (xnthread) and pod (xnpod)abstractions which exhibit the following characteristics:

微內核提供了線程對象(xnthread)和pod抽象(xnpod)的具體表示,具有以下特點:

?    Threads are scheduled according to a 32bit integer priority value,using a preemptive algorithm. Priority ordering can be increasing or decreasingdepending on the pod configuration.

?    線程通過1個32bit的整形優先級值,利用搶占邏輯來實現再調度。優先級可以增加也能夠下降,具體依賴于pod的配置。

?    A thread can be either waiting for initialization, forciblysuspended, pending on a resource, delayed for a count of ticks, ready-to-run orrunning.

?    線程要末是等待初始化,要末是被強迫suspended,要末是等待資源進入pending,要末是等待1系列的時鐘tick,要末是等待運行或運行中。

?    Timed wait for a resource can be bounded by a per-thread watchdog.

?    資源的時間等待可以被每一個線程的看門狗的所限定。

?    The priority inheritance protocol is supported to prevent threadpriority inversion when it is detected by a synchronization object.

?    優先級的繼承協議支持,當1個同步目標檢測到時,將禁止優先級的反轉。

?    A group of threads having the same base priority can undergo around-robin scheduling, each of them being given an individual time quantum.

?    具有相同優先級的1組線程可以進行循環調度,每一個個體都給定1個單獨的時間片。

?    A support for sending signals to threads and running asynchronousservice routines (ASR) to process them is built-in.

?    內建的信號發送機制,和異步服務支持機制

?    FPU support can be optionally enabled or disabled for any thread atcreation time.

?    線程創建時,選擇性的支持FPU.

?    Each thread can enter a disjunctive wait on multiple resources.

?    等待多重資源時,每一個線程都可進入1個獨立的等待不干擾。

1.4.2 . Basic synchronization support

The nucleus provides a synchronizationobject abstraction (xnsynch) aimed atimplementing the common behaviour of RTOS resources, which has the followingcharacteristics:

?    Support for the priority inheritance protocol, in order to preventpriority inversion problems. The implementation is shared with the schedulercode.

?    Support for time-bounded wait and forcible deletion with waitersawakening.

微內核提供了1個同步對象抽象(xnsynch),旨在RTOS資源上具有1般的行動,具有以下特點:

?    支持優先級繼承,避免優先級反轉。實現和調度器代碼同享。

?   支持限定時間的等待和強迫刪除戶的等待喚醒。

1.4.3 . Timer and clock management

The nucleus needs a time source to providethe time-related services to the upper interfaces. The timer hardware needs tobe configured so that a user-defined routine is called according to a givenfrequency. On architectures that provide a oneshot-programmable time source,the system timer can operate either in aperiodic or periodic mode. Using theaperiodic mode still allows to run periodic nucleus timers over it: theunderlying hardware will simply be reprogrammed after each tick by the timermanager using the appropriate interval value.

Each incoming clock tick is announced tothe timer manager which fires in turn the timeout handlers of elapsed timers.The scheduler itself uses per-thread watchdogs to wake up threads undergoing abounded time wait, while waiting for a resource availability or being delayed.

A special care has been taken to offerbounded worst-case time for starting, stopping and maintaining timers. Thetimer facility is based on the timer wheel algorithm[11] described by Adam M.Costello and George Varghese, which is implemented in the NetBSD operatingsystem for instance.

微內核需要1個時鐘源,為上層接口提供時鐘相干服務接口。配置硬件的時間片,讓利用依照給定的頻率調用用戶定義的服務。架構上提供了1個oneshot的可編程的時鐘源,系統時間片可以依照不定期或定期模式運行。不定期周期模式依然運行定時周期的微內核時間片。經過每一個tick以后,由時間片管理器通過1個適合的內部值對硬件進行重新編程。

每個的時鐘tick都被通知到時間片管理器,即流逝時間的處理者。調度器本身利用每一個線程自己的watchdog,由于1個資源的獲得或其他緣由等待,在經過1個有限的時間等待后,來喚醒線程。

提供1個最壞情況的有限的時間,進行啟動、停止或保持,需要進行特別的關注。基于時間片輪轉的算法的時間片實現1鍵在NETBSD系統上實現。

1.4.4 . Basic memory allocation

Xenomai's nucleus provides dynamic memory allocation support withreal-time guarantee, based on McKusick's and Karels' proposal for a generalpurpose memory allocator[10]. Any number of memory heaps can be maintaineddynamically by Xenomai, only limited by the actual amount of system memory.

基于McKusick和Karels的1般目的性的內存分配的建議,Xenomai內核提供了1種動態的內存分配保證了實時性的要求。任何的數量的內存堆都可以有xenomai動態保持,唯1的限制在于系統的內存的數量。

生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 毛片国产 | 一级黄色毛片视频 | 亚洲精品乱码久久久久久蜜桃不爽 | 精品久久久久久久久久久久久久久久久 | 国产亚洲精品久久久久动 | 国产成人久久 | 欧美色欧美亚洲另类二区 | h视频国产| 国产午夜精品久久 | 一区三区视频在线观看 | 免费一级毛片视频 | 亚洲一区在线视频 | 欧美日韩国产一区二区在线观看 | 亚洲另类欧美日韩 | 欧美xxxx网站 | 黄色片免费网址 | 欧洲亚洲女同hd | 欧美精品一卡 | 国产伦精品一区二区三区视频孕妇 | 国产在线视频一区 | 黄色片av| 欧美激情专区 | 亚洲一区二区免费看 | 成人短视频在线观看 | 一区二区视频在线观看 | 日韩精品免费一区二区在线观看 | 国产激情在线观看 | 亚洲一区二区久久 | a一级黄色大片 | 精品网址| 亚洲欧美视频在线观看 | 日韩伦理电影网 | 日韩理论在线 | 日本欧美一区二区三区 | 久久久久久久国产精品影院 | 激情毛片| 99精品一区| 国产精品久久久久久亚洲调教 | 人人爽人人爽 | 成人在线黄色 | 91国内精品久久 |