嵌入式系统软件教程5.pptx
《嵌入式系统软件教程5.pptx》由会员分享,可在线阅读,更多相关《嵌入式系统软件教程5.pptx(92页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、会计学1嵌入式系统软件教程嵌入式系统软件教程5Taskn nEach 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.n nA tasks context is saved in the task control block(TCB).第1页/共92页Taskn nA tasks context includes:A tasks context includes:
2、-a thread of execution;that is,the tasks program counter -a thread of execution;that is,the tasks program counter -the CPU registers and(optionally)floating-point registers -the CPU registers and(optionally)floating-point registers -I/O assignments for standard input,output,and error -I/O assignment
3、s for standard input,output,and error -a delay timer -a delay timer -a time-slice timer -a time-slice timer -kernel control structures -kernel control structures -signal handlers -signal handlers -debugging and performance monitoring values -debugging and performance monitoring values第2页/共92页Taskn n
4、The default task scheduling algorithm in wind is priority-based preemptive scheduling.n nRound Robin is an optional algorithm.n nThe wind kernel has 256 priority levels,numbered 0 through 255.n nPriority 0 is the highest and priority 255 is the lowest.第3页/共92页Task Scheduler Control Routines第4页/共92页T
5、askn nTask LockTask LockWhen a task disables the scheduler by calling taskLock(),no priority-based preemption When a task disables the scheduler by calling taskLock(),no priority-based preemption can take place while that task is running.can take place while that task is running.If the task explicit
6、ly blocks or suspends,the scheduler selects the next highest-priority If the task explicitly blocks or suspends,the scheduler selects the next highest-priority eligible task to execute.eligible task to execute.When the preemption-locked task unblocks and begins running again,preemption is When the p
7、reemption-locked task unblocks and begins running again,preemption is again disabled.again disabled.The taskLock()prevent task context switching,but do not lock out interrupt handling.The taskLock()prevent task context switching,but do not lock out interrupt handling.第5页/共92页Task Control Routine第6页/
8、共92页Taskn ntaskSpawnn nTask Name and ID Routinesn nTask Information Routinesn nTask Deleting Routinesn nTask Control Routinesn nTask Hook Routines第7页/共92页Task Spawn第8页/共92页Task Name and ID Routines第9页/共92页Task Information Routines第10页/共92页Task Information Routines第11页/共92页Task Deleting Routines第12页/
9、共92页Task Deleting Routines第13页/共92页Task Control Routines第14页/共92页Task Hook Routines第15页/共92页Shared Code and Reentrancyn nA single copy of code executed by multiple tasks is called shared code.n nA subroutine is reentrant if a single copy of the routine can be called from several task contexts simult
10、aneously without conflict.n nModify global or static variables.第16页/共92页Code Reentrancy Solutionsn nDynamic Stack Variablesn nGuarded Global and Static Variablesn nTask Variables第17页/共92页Dynamic Stack Variables第18页/共92页Guarded Global and Static Variablesn nProviding a mutual-exclusion mechanism to p
11、rohibit tasks from simultaneously executing critical sections of code.第19页/共92页Task Variables第20页/共92页Intertask Communicationn nShared Data Structuren nMutual Exclusionn nSemaphoresn nMessage Queuesn nPipesn nNetwork Intertask Communicationn nSignals第21页/共92页Shared Data Structuresn nGlobal variables
12、n nLinear buffersn nRing buffersn nLinked listsn nPointers第22页/共92页Shared Data Structures第23页/共92页Mutual Exclusionn nDisable interruptsn nDisable preemptionn nResource locking with semaphores第24页/共92页Disable Interruptsn nThe most powerful methodn nIt prevents the system from responding to external e
13、vents for the duration of these locks.n nKeep the duration of interrupt lockouts short.第25页/共92页Preemptive locksn nLess restrictive form of mutual exclusion.n nNo other task is allowed to preemptive the current executing task,ISR are able to execute.n nTasks of higher priority are unable to execute
14、until the locking task leaves the critical region.第26页/共92页Semaphoresn nHighly optimized and provide the fastest intertask communication mechanism in VxWorks.n nThree types of Wind semaphores:-Binary-Mutual exclusion-Counting第27页/共92页Semaphore Control Routines第28页/共92页Binary Semaphore第29页/共92页Binary
15、 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页/共92页Mutual Semaphore-Recursive Resource Access第36页/共92页Mutual Semaphore-Recurs
16、ive Resource Access第37页/共92页Counting Semaphores第38页/共92页Message Queuen nMessage queues allow a variable number of messages,each of variable Message queues allow a variable number of messages,each of variable length,to be queued.Tasks and ISRs can send messages to a message length,to be queued.Tasks
17、and ISRs can send messages to a message queue,and tasks can receive message form a message queue.queue,and tasks can receive message form a message queue.n nMultiple tasks can send to and receive from the same message queue.Full-Multiple tasks can send to and receive from the same message queue.Full
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 嵌入式 系统软件 教程
限制150内