




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Task Each 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 control block (TCB).第1页/共92页Task A tasks context includes: - a thread of execution; that is, the tasks program
2、 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 handlers - debugging and performance monitoring values第2页/共92页Task The default task scheduling algo
3、rithm 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.第3页/共92页Task Scheduler Control Routines第4页/共92页Task Task LockWhen a task disables the
4、 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 preemption-locked task unblocks and begins running again, preemption i
5、s again disabled.The taskLock() prevent task context switching, but do not lock out interrupt handling.第5页/共92页Task Control Routine第6页/共92页Task taskSpawn Task Name and ID Routines Task Information Routines Task Deleting Routines Task Control Routines Task Hook Routines第7页/共92页Task Spawn第8页/共92页Task
6、Name and ID Routines第9页/共92页Task Information Routines第10页/共92页Task Information Routines第11页/共92页Task Deleting Routines第12页/共92页Task Deleting Routines第13页/共92页Task Control Routines第14页/共92页Task Hook Routines第15页/共92页Shared Code and Reentrancy A single copy of code executed by multiple tasks is called
7、 shared code. A subroutine is reentrant if a single copy of the routine can be called from several task contexts simultaneously without conflict. Modify global or static variables.第16页/共92页Code Reentrancy Solutions Dynamic Stack Variables Guarded Global and Static Variables Task Variables第17页/共92页Dy
8、namic Stack Variables第18页/共92页Guarded Global and Static Variables Providing a mutual-exclusion mechanism to prohibit tasks from simultaneously executing critical sections of code.第19页/共92页Task Variables第20页/共92页Intertask Communication Shared Data Structure Mutual Exclusion Semaphores Message Queues
9、Pipes Network Intertask Communication Signals第21页/共92页Shared Data Structures Global variables Linear buffers Ring buffers Linked lists Pointers第22页/共92页Shared Data Structures第23页/共92页Mutual Exclusion Disable interrupts Disable preemption Resource locking with semaphores第24页/共92页Disable Interrupts Th
10、e most powerful method It prevents the system from responding to external events for the duration of these locks. Keep the duration of interrupt lockouts short.第25页/共92页Preemptive locks Less restrictive form of mutual exclusion. No other task is allowed to preemptive the current executing task, ISR
11、are able to execute. Tasks of higher priority are unable to execute until the locking task leaves the critical region.第26页/共92页Semaphores Highly optimized and provide the fastest intertask communication mechanism in VxWorks. Three types of Wind semaphores:- Binary- Mutual exclusion- Counting第27页/共92
12、页Semaphore Control Routines第28页/共92页Binary Semaphore第29页/共92页Binary Semaphore第30页/共92页Binary Semaphore - Mutual Exclusion第31页/共92页Binary Semaphore - Mutual Exclusion第32页/共92页Binary Semaphore - Synchronization第33页/共92页Binary Semaphore - Synchronization第34页/共92页Binary Semaphore - Synchronization第35页/共
13、92页Mutual Semaphore - Recursive Resource Access第36页/共92页Mutual Semaphore - Recursive Resource Access第37页/共92页Counting Semaphores第38页/共92页Message Queue Message queues allow a variable number of messages, each of variable length, to be queued. Tasks and ISRs can send messages to a message queue, and t
14、asks 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.第39页/共92页Message Queues第40页/共92页Wind Message Queue Control第41页/共92页Message Queu
15、e Example第42页/共92页Message Queue Example第43页/共92页Message Queue Example第44页/共92页Message Queues第45页/共92页Pipes Pipes provide an alternative interface to the message queue facility that goes through the VxWorks I/O system.第46页/共92页Sockets In VxWorks, the basis of intertask communication across the networ
16、k is sockets. VxWorks supports the Internet protocols 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.第47页/共92页RPC Remote Procedure Calls (RPC) is a facility that allows a process on a machi
17、ne to call a procedure that is executed by another process on either the same machine or a remote machine.第48页/共92页Signal Signals 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
18、 of execution and executes the task-specified signal handler routine.第49页/共92页Signal Signals 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-s
19、pecified signal handler routine.第50页/共92页Event VxWorks events are means of communication between 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. 第51页/共92页Event Sending
20、 and Receiving EventsEvents can be sent from a resource to a task, from an ISR to a task, or directly 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
21、events.第52页/共92页Event Registering for EventsOnly one task can register itself to receive events from a resource. If 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 th
22、at it is free, it does not mean that resource is reserved.第53页/共92页Event Free Resource Definition Mutex Semaphore- A mutex semaphore 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
23、is waiting for it.第54页/共92页Event Free Resource Definition Counting Semaphore- A counting semaphore is considered free when its counts is nonzero 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 a
24、rrival of a message in that queue.第55页/共92页Event Sending and Receiving EventsEvents can be sent from a resource to a task, from an ISR to a task, or directly between two tasks. Waiting for EventsA task can wait for multiple events from one or more resources. Each source can send multiple events, and
25、 a task can also wait to receive only one event, or all events.第56页/共92页Watchdog Timers VxWorks 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
26、system clock.第57页/共92页Watchdog Timers Calls第58页/共92页Watchdog Timers Example第59页/共92页Event Register Routine第60页/共92页Interrupt Service Routine第61页/共92页intConnect Routine第62页/共92页Appendix: Shell Run a shell Variables in shell C commands in shell: printf Shell commands: i, ti, w, tw, 第63页/共92页Run a shell 第64页/共92页Variables in shell第65页/共92
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 银川市中石油2025秋招笔试模拟题含答案炼油工艺技术岗
- 中国联通天水市2025秋招财务审计类专业追问清单及参考回答
- 临沧市中石油2025秋招笔试模拟题含答案炼油设备技术岗
- 渭南市中储粮2025秋招面试专业追问题库财务资产岗
- 中国广电神农架林区2025秋招写作案例分析万能模板直接套用
- 国家能源白银市2025秋招面试专业追问及参考财务审计岗位
- 2025年普法课堂考试题及答案
- 鸡西市中储粮2025秋招质检化验岗高频笔试题库含答案
- 益阳市中储粮2025秋招面试专业追问题库财务资产岗
- 大唐电力哈尔滨市2025秋招综合管理专业面试追问及参考回答
- 不知足常乐最终辩论稿
- 2025云南昆明元朔建设发展有限公司第一批收费员招聘20人考试参考试题及答案解析
- 2026农业银行四川省分行秋季校园招聘1374人考试参考题库及答案解析
- 建筑垃圾回收利用全过程信息化管理方案
- 第9课《天上有颗“南仁东星”》 课件 2025-2026学年统编版语文八年级上册
- 《山水相逢》课件2025-2026学年人美版(2024)八年级美术上册
- 法警安全检查培训课件
- 人员密集场所安全培训教学课件
- 知识产权保护与运用培训课件
- 2025年广东省政府采购评审专家考试真题含答案
- 新疆省中考英语真题全解析
评论
0/150
提交评论