【正文】
itectures that have both supervisor and user modes of operation, Nucleus PLUS application tasks typically run in supervisor mode. This is because application tasks make direct calls to operating system services that utilize privileged instructions. This method reduces service call overhead and is also much easier to implement. Of course, this method allows the tasks to access anything and everything.The user is responsible for providing its own initialization routine, which is called Application Initialize. This routine should create the tasks, queues, and other system objects that are required when the system starts. If the application does not utilize dynamic creation/deletion of system objects during runtime, all of the required system objects may be created in begins immediately after the user’s Application Initialize routine returns.In some target environments, the lowlevel system initialization files, , , or may require modification. These files initialize the system timer interrupt, available memory, and other entities that are inherently processor or board specific.All user code that references Nucleus PLUS services and/or data types must include the file . This file contains data type definitions, constant definitions, and function prototypes for all of the Nucleus PLUS services. This file is specific to each port of Nucleus PLUS.The main Nucleus PLUS include file, , contains function prototypes that match those defined in the Nucleus PLUS reference manual. However, the NU_* functions do not really exist. For most Nucleus PLUS services, there exists a function that really does the work and a .shell. Function that checks for errors in the user’s request before calling the real function. Depending on the error checking conditional define,NU_NO_ERROR_CHECKING, the Nucleus PLUS service call is mapped, through macro substitution, to the appropriate underlying function. This facilitates plete elimination of error checking when it is not required.There are several conditional flags available when piling application programs, Nucleus PLUS application elements may disable error checking on parameters supplied to Nucleus PLUS services by defining NU_NO_ERROR_CHECKING with a piler mand line option. This results in a substantial increase in runtime performance, and also reduces code size. Application data structures defined in may be mapped directly to the internal Nucleus PLUS data structures by defining the NU_DEBUG option during pilation. This allows the user to directly examine the internals of each Nucleus PLUS data structure within a sourcelevel debugging environment. If the NU_DEBUG option is used, it is often a good idea to rebuild all of the Nucleus PLUS source code with the same NU_DEBUG option.Processor and development tool dependencies in Nucleus PLUS have been isolated to four files. Three of the files (INT.?, TCT.?, and TMT.?) are written in assembly language. These files provide the lowlevel, runtime environment for the underlying target environment. The third file () is included, either directly or indirectly, by all of the files in the system. This file defines various data types and other processor and development tool specific information.The INT.[S, ASM, or SRC] file is responsible for providing lowlevelInitialization and services for accessing the processors interrupt vector table. ThisFile also contains default Interrupt Service Routine (ISR) handlers. The functionINT_Initialize is specific to a given target board. For example, if the targetProcessor is not able to generate an internal timer interrupt, setting up the timerInterrupt bees board specific. This means that a modified version of INT might be necessary for different boards even though they share the same processor architecture.The TCT.[S, ASM, or SRC] file is primarily responsible for transferring control between threads and the system. A thread is defined as either a Nucleus PLUS task or a Nucleus PLUS HISR. This file contains all of the code necessary to perform context switches between tasks and HISRs. Additionally, this file contains code necessary for handling protection conflicts and task signals.The TMT.[S, ASM, or SRC] file is primarily responsible for handling Nucleus PLUS timer services, including the timer interrupt handler. In most ports, the timer interrupt handler is designed for lowoverhead operation when no timer has expired.The include file is included by all Nucleus PLUS source files – either directly or indirectly. Application files that reference Nucleus PLUS services and/or data types must also include . This file defines a variety of data types, interrupt lockout/enable values, the number of interrupt vectors, the size of system control blocks, and other target specific information.There are several different version layers in a Nucleus PLUS system. The system version is defined by the ASCII string RLD_Release_String in the file . This version contains the current version of the generic C source code as well as the version of the target specific code. For example, the release string for version of the DOS/Borland target specific code with version of the generic code would be:Copyright (c) 199x ATI Nucleus PLUS DOS Borland C Version . Nucleus PLUS also has version information for each file. The version information in the header block of each file identifies the version of that specific file. In many cases, the version in the file header is quite different than the version of the system. Each function in a file also contains version information in its header. The version information specified near the bottom of each function’s header indicates what changes were made to the function and which version of the file they apply to.Nucleus 操作系統(tǒng)Nucleus PLUS 是為實時嵌入式應(yīng)用而設(shè)計的一個搶先式多任務(wù)操作系統(tǒng)內(nèi)核,其95%的代碼是用ANSIC 寫成的,因此非常便于移植并能夠支持大多數(shù)類型的處理器。從實現(xiàn)角度來看,Nucleus PLUS 是一組C 函數(shù)庫,應(yīng)用程序代碼與核心函數(shù)庫連接在一起,生成一個目標(biāo)代碼,下載到目標(biāo)板的RAM 中或直接燒錄到目標(biāo)板的ROM 中執(zhí)行。在典型的目標(biāo)環(huán)境中,Nucleus PLU