vxworks嵌入式操作系統ppt課件_第1頁
vxworks嵌入式操作系統ppt課件_第2頁
vxworks嵌入式操作系統ppt課件_第3頁
vxworks嵌入式操作系統ppt課件_第4頁
vxworks嵌入式操作系統ppt課件_第5頁
已閱讀5頁,還剩88頁未讀, 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、嵌入式軟件VxWorks編程介紹 鄒昕光哈爾濱工業大學自動化測控所 聯系電話:86413531 - 609: AgendaTaskIntertask communicationISRTaskEach task has its own context, which is the CPU environment and system resources that the task sees each time it is scheduled to run by the kernel.A tasks context is saved in the task contr

2、ol block (TCB).TaskA tasks context includes: - a thread of execution; that is, the tasks program counter - the CPU registers and (optionally) floating-point registers - I/O assignments for standard input, output, and error - a delay timer - a time-slice timer - kernel control structures - signal han

3、dlers - debugging and performance monitoring valuesTaskThe default task scheduling algorithm in wind is priority-based preemptive scheduling.Round Robin is an optional algorithm.The wind kernel has 256 priority levels, numbered 0 through 255.Priority 0 is the highest and priority 255 is the lowest.T

4、ask Scheduler Control RoutinesTaskTask LockWhen a task disables the scheduler by calling taskLock(), no priority-based preemption can take place while that task is running.If the task explicitly blocks or suspends, the scheduler selects the next highest-priority eligible task to execute.When the pre

5、emption-locked task unblocks and begins running again, preemption is again disabled.The taskLock() prevent task context switching, but do not lock out interrupt handling.Task Control RoutineTasktaskSpawnTask Name and ID RoutinesTask Information RoutinesTask Deleting RoutinesTask Control RoutinesTask

6、 Hook RoutinesTask SpawnTask Name and ID RoutinesTask Information RoutinesTask Information RoutinesTask Deleting RoutinesTask Deleting RoutinesTask Control RoutinesTask Hook RoutinesShared Code and ReentrancyA single copy of code executed by multiple tasks is called shared code.A subroutine is reent

7、rant if a single copy of the routine can be called from several task contexts simultaneously without conflict.Modify global or static variables.Code Reentrancy SolutionsDynamic Stack VariablesGuarded Global and Static VariablesTask VariablesDynamic Stack VariablesGuarded Global and Static VariablesP

8、roviding a mutual-exclusion mechanism to prohibit tasks from simultaneously executing critical sections of code.Task VariablesIntertask CommunicationShared Data StructureMutual ExclusionSemaphoresMessage QueuesPipesNetwork Intertask CommunicationSignalsShared Data StructuresGlobal variablesLinear bu

9、ffersRing buffersLinked listsPointersShared Data StructuresMutual ExclusionDisable interruptsDisable preemptionResource locking with semaphoresDisable InterruptsThe most powerful methodIt prevents the system from responding to external events for the duration of these locks.Keep the duration of inte

10、rrupt lockouts short.Preemptive locksLess restrictive form of mutual exclusion.No other task is allowed to preemptive the current executing task, ISR are able to execute.Tasks of higher priority are unable to execute until the locking task leaves the critical region.SemaphoresHighly optimized and pr

11、ovide the fastest intertask communication mechanism in VxWorks.Three types of Wind semaphores:- Binary- Mutual exclusion- CountingSemaphore Control RoutinesBinary SemaphoreBinary SemaphoreBinary Semaphore - Mutual ExclusionBinary Semaphore - Mutual ExclusionBinary Semaphore - SynchronizationBinary S

12、emaphore - SynchronizationBinary Semaphore - SynchronizationMutual Semaphore - Recursive Resource AccessMutual Semaphore - Recursive Resource AccessCounting SemaphoresMessage QueueMessage queues allow a variable number of messages, each of variable length, to be queued. Tasks and ISRs can send messa

13、ges to a message queue, and tasks can receive message form a message queue.Multiple tasks can send to and receive from the same message queue. Full-duplex communication between two tasks generally requires two message queues, one for each direction.Message QueuesWind Message Queue ControlMessage Que

14、ue ExampleMessage Queue ExampleMessage Queue ExampleMessage QueuesPipesPipes provide an alternative interface to the message queue facility that goes through the VxWorks I/O system.SocketsIn VxWorks, the basis of intertask communication across the network is sockets.VxWorks supports the Internet pro

15、tocols TCP and UDP.TCP provides reliable, guaranteed, two-way transmission of data with stream sockets.UDP provides a simple but less robust form of communication.RPCRemote Procedure Calls (RPC) is a facility that allows a process on a machine to call a procedure that is executed by another process

16、on either the same machine or a remote machine.SignalSignals asynchronously alter the control flow of a task.Any task or ISR can raise a signal for a particular task.The task being signaled immediately suspends its current thread of execution and executes the task-specified signal handler routine.Si

17、gnalSignals asynchronously alter the control flow of a task.Any task or ISR can raise a signal for a particular task.The task being signaled immediately suspends its current thread of execution and executes the task-specified signal handler routine.EventVxWorks events are means of communication betw

18、een tasks and interrupt routine, between tasks and other tasks, or between tasks and VxWorks objects.VxWorks objects are referred to as resources such as semaphores and message queue. EventSending and Receiving EventsEvents can be sent from a resource to a task, from an ISR to a task, or directly be

19、tween two tasks.Waiting for EventsA task can wait for multiple events from one or more resources. Each source can send multiple events, and a task can also wait to receive only one event, or all events.EventRegistering for EventsOnly one task can register itself to receive events from a resource. If

20、 another task subsequently registers with the same resource, the previously registered task is automatically unregistered.Freeing ResourceWhen a resource sends to a task to indicate that it is free, it does not mean that resource is reserved.EventFree Resource DefinitionMutex Semaphore- A mutex sema

21、phore is considered free when it no longer has an owner and no one is pending on it.Binary Semaphore- A binary semaphore is considered free when no task owns it and no one is waiting for it.EventFree Resource DefinitionCounting Semaphore- A counting semaphore is considered free when its counts is no

22、nzero and no one is pending on it.Message Queue- A message queue is considered free when a message queue is present in the queue and no one is pending for the arrival of a message in that queue.EventSending and Receiving EventsEvents can be sent from a resource to a task, from an ISR to a task, or d

23、irectly between two tasks.Waiting for EventsA task can wait for multiple events from one or more resources. Each source can send multiple events, and a task can also wait to receive only one event, or all events.Watchdog TimersVxWorks includes a watchdog-timer mechanism that allows any C function to be connect to a specified time delay.Function invoked by watchdog timers execute as interrupt service code at the interrupt level of the system clock.Watchdog Timers CallsWatchdog Timers ExampleEvent Register RoutineInt

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論