tornadovxworks培训(编辑修改稿)内容摘要:

em debugging by Unsetting the VX_DEALLOC_STACK option or, Using a delete hook. taskDelete(tid) 嵌入式培训专题 微迪软件培训中心 Resource Reclamation Contrary to the philosophy of sharing system resources among all tasks. Can be an expensive process, which must be the application‟s responsibility. TCB and stack are the only resources automatically reclaimed. Tasks are responsible for cleaning up after themselves. Deallocating memory. Releasing locks to system resources. Closing files which are open. Deleting child / client tasks when parent / server exits. 嵌入式培训专题 微迪软件培训中心 RealTime Multitasking Introduction Task Basics Task Control Error Status System Tasks 嵌入式培训专题 微迪软件培训中心 Task Restart taskRestart (tid) Task is terminated and respawned with original arguments and tid. Usually used for error recovery. 嵌入式培训专题 微迪软件培训中心 Task Suspend / Resume taskSuspend (tid) Makes task ineligible to execute. Can be added to pended or delayed state. taskResume (tid) Removes suspension. Usually used for debugging and development purposes. 嵌入式培训专题 微迪软件培训中心 Task Delay To delay a task for a specified number of system clock ticks. To poll every 1/7 second: FOREVER { taskDelay (sysClkRateGet() / 7)。 ... } STATUS taskDelay (ticks) Use sysClkRateSet() to change the clock rate. Accurate only if clock rate is a multiple of seven ticks / seconds. Can suffer from “drift.” 嵌入式培训专题 微迪软件培训中心 Reentrancy and Task Variables If tasks access the same global or static variables, the resource can bee corrupted (called a race condition). Possible Solutions: Task Variables cause a 32bit value to be saved and restored on context switchs, like a register. Use only stack variables in applications. Protect the resource with a semaphore. Use task variables to make the variable private to a task Caveat: task variables increase context switch times. See the taskVarLib manual pages for details. 嵌入式培训专题 微迪软件培训中心 Task Hooks Userdefined code can be executed on every context switch, at task creation, or at task deletion: taskSwitchHookAdd () taskCreateHookAdd () taskDeleteHookAdd () VxWorks uses a switch hook to implement task variables. See manual pages on taskHookLib for details. 嵌入式培训专题 微迪软件培训中心 Task Information Like i(), but also displays: Can also use show (): show (tNetTask, 1) Stack information Task options CPU registers FPU registers (if the VX_FP_TASK option bit is set) ti (taskNameOrId) 嵌入式培训专题 微迪软件培训中心 Task Browser To obtain information about a specific task, click on the task‟s summary line in the main target browser. 嵌入式培训专题 微迪软件培训中心 What is POSIX ? Originally, an IEEE mittee convened to create a standard interface to UNIX for: VxWors supports almost all of the POSIX Realtime Extensions. Increased portability. Convenience. Context switch times are very fast. Text, data, and bss are stored in a mon, global address space. The POSIX realtime extensions are based on implicit assumptions about the UNIX process model which do not always hold in VxWorks. In VxWorks, 嵌入式培训专题 微迪软件培训中心 What does VxWorks support ? Library Description aioPxLib Asynchornous I/O semPxLib POSIX Semaphores mqPxLib POSIX Message Queues mmanPxLib POSIX Memory Management schedPxLib POSIX Scheduler Interface sigLib POSIX Signals timerLib, clockLib POSIX Timer/Clock Interface dirLib File/Directory Information 嵌入式培训专题 微迪软件培训中心 RealTime Multitasking Introduction Task Basics Task Control Error Status System Tasks 嵌入式培训专题 微迪软件培训中心 Error Status • VxWorks里使用一个全局整型变量 errno来描述错误信息 – 程序执行过程中我们可以设置并调用一些函数例程来检测错误信息,并针对错误信息设置相应的错误号 – 然后调用一些函数例程检测错误号,当程序执行异常时可以根据错误号发现相应的错误 嵌入式培训专题 微迪软件培训中心 Errno and Context Switches At each context switch, the kernel saves and restores the value of errno. TCB errorStatus errno 嵌入式培训专题 微迪软件培训中心 Setting Errno Lowest level routine to detect an error sets errno and returns ERROR: STATUS myRoutine () { ... if (myNumFlurbishes = MAX_FLURBISH) { errno = s_myLib_TOO_MANY_FLURBISHES。 return (ERROR)。 } … pMem=malloc(sizeof(myStruct))。 if ( pMem== NULL) { /* malloc() sets errno don’t redefine it */ return (ERROR)。 } ... } 嵌入式培训专题 微迪软件培训中心 Examining Errno Examine errno to find out why a routine failed. if (reactorOk() == ERROR) { switch (errno) { case S_rctorLib_TEMP_DANGER_ZONE: startShutDown ()。 break。 case S_rctorLib_TEMP_CRITICAL_ZONE: logMsg (“Run!”)。 break。 case S_rctorLib_LEAK_POSSIBLE: checkVessel ()。 break。 default: startEmergProc ()。 } } errno is only valid after an error occurs. 嵌入式培训专题 微迪软件培训中心 Interpreting Errno VxWorks uses the 32bit value errno as follows: Module numbers are defined in . Each module defines its own error numbers in its header file. Module number 0x11 (define in to be memLib) and Error number 0x01 (defined in to be “not enough memory”). For example, an errno of 0x110001 would be: module error number 31 15 0 嵌入式培训专题 微迪软件培训中心 Error Messages VxWorks uses an error symbol table (statSymTbl) to convert error numbers to error messages. To print the error message for the current task‟s error status to STD_ERR: perror (“darn”) darn: S_Drv_NO_SUCH_FILE_OR_DIR To print the error message associated with an error number to the WindSh console : printErrno (0x110001) S_memLib_NOT_ENOUGH_MEMORY 嵌入式培训专题 微迪软件培训中心 UserDefined Error Codes To get perror() to print your error messages: 1. Modify to reserve a module number: define M_myLib (501 16) 2. Define error macros in your header file (which must be in the wind/target/h directory): define S_myLib_。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。