Home
RTXC 3.2 TRAINING COURSE jrg.ppt
Contents
1. Priority 3 Task C gains ownership of Resource with KS lock wl t Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC RESOURCES PRIORITY INVERSION Task C Priority 3 Task A preempts Task C and needing the Resource attempts to gain ownership with a KS lock wlt kernel service KS lock Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC RESOURCES PRIORITY INHERITANCE Task C continues to own the Resource and has its priority temporarily changed to that of Task A Sk A is blocked on the Resource source and is waiting ren though it has the highest priority Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC RESOURCES PRIORITY INHERITANCE Task C temporarily gets Task A s Priority en Task C finishes i the resource it is rned to its old priority Task A preempts and IS Resource Waiters List Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC RESOURCES RESOURCE KERNEL SERVICES KS lock resource Acquire exclusive use of resource returns RC GOOD if successful RC BUSY If resource locked by another owner KS lockw resource gt Same as KS lock but if resource is BUSY wait until resource available KS lockt resource ticks gt Same as KS lockw but limit duration of wait to period of ticks unlock resource gt Release exclusiv
2. Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved Systems Inc o Total System 948 bytes Total UserRAM ROM 10440 532 bytes NUM 12 52 PM Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved Systems Inc o Total System RAM 948 bytes Total User RAM ROM 10440 592 bytes NUM 12 53 PM Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved Systems Inc o SYSgen LOADING A TASK DEFINITION FILE gt RTXC 5 ystem Generation C RTXC E xamplestdemo E xercisessdemol demol Edt View Project Window Import Print Setup Exit Import an Old Class Definition File Copyright O 2008 Quadros Systems Inc All Rights Reserved SYSgen TASK DEFINITION WINDOW RTXC System Generation C RTXAC Examples demo E xercises demol demo File Edit View E Window Help eT dg Task Definition H Name Priority Entry Stack Start FPU Description RTACBUG RTXC Debugger cal Calendar TOD prtsc PrtSc Driver comodru COM Output Driver comidru COM Input Driver conodru CONsole Output conidru CONsole Input prtdump Screen dump prndru PRN Driver 4 2 3 4 5 6 7 8 9 Dynamic Objects O System RAM 580 bytes User RAM ROM 5120 340 bytes Total System RAM 948 bytes Total User RAM ROM 10440 592 bytes NUM 12 54 PM Quadr Copyright O 2008 Quadros Systems Inc All Rights Reserve
3. T4 1 Iko JS uw e Pe M E MP e s Pom e da um i EN IM O t L ad IDEE TU M ETC UN E u Ie SU xA c UN DE E gt A m d Copyright O 2008 Quadros Systems Inc All Rights Reserved APPLICATION DESIGN Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved APPLICATION DEVELOPMENT PROCESS SY apen Application Code RTXC Source Code gt p lt Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved E APPLICATION DESIGN SUMMARY Define requirements of the system Define necessary Kernel Objects Define tasks and their functionality Define priorities and synchronization Define communication mechanisms Ensure compliance with rules and policies of RT XC for efficient design Iterative process use information from RTXCbug to refine system design Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved v s RTXC SOURCE CODE Quadr Copyright O 2008 Quadros Systems Inc All Rights Reserved APPLICATION DEVELOPMENT PROCESS Doo Application Design SY apen Application Code Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC SOURCE CODE SUMMARY Most configuration options are set in rtxcopts h Some options are set in the make file Should require few changes once configured The source code is compiled and the object files are added to a li
4. POLICIES establish the fundamental principles of the kernel design RULES implement these policies Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o RTXC POLICIES FUNDAMENTAL PRINCIPLES Allocation of system resources Scheduling methods Responsiveness and performance Flexibility Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC BASIC POLICIES RTXC should contain sufficient numbers and types of services to make the kernel useful to a variety of applications RTXC should employ a multitasking design to achieve maximum CPU efficiency RTXC primary multitasking method should be event driven Each task should have a priority indicative of its relative scheduling importance Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved v s RTXC BASIC POLICIES RAM usage should be kept to a minimum RT XC should impose a minimum overhead on the application RT XC performance should be deterministic to the greatest extent possible Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved E RTXC BASIC RULES he Current Task is the highest priority task in the system that is not blocked he Current Task maintains control of the CPU either until it runs to completion yields becomes blocked by resource unavallability or is preempted fa task of higher priority than the Current Task
5. RTXC Real Time Executive in C Smart Starts Here Quadros Systems Inc ee COURSE CONTENT Day 1 Unit 1 RTXC Overview Unit 2 Application Development Process Exercises Unit 3 Tasks and Memory Partitions Exercises Day2 Unit 4 Semaphores Timers and Resources Exercises Unit 5 Queues Mailboxes and Messages Exercises Unit 6 Interrupt Handling Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC TRAINING UNIT 1 RTXC Overview Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o RTXC V3 2 PRODUCT OVERVIEW Out of the Box use with your compiler and processor Written in ANSI C for portability 600 page RTXC User s Manual f kernel object classes using 72 Kernel Services Event driven multitasking design with Preemptive scheduling Support for Time Sliced and Round Robin scheduling Configurable ROMable and extensible System level debug utility RTXCbug System generation utility SYSgen Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved v s RTXC IS PROCESSOR INDEPENDENT Common API for all processors Common RTXC User s Manual RTXC for a particular processor is called a PORT Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o RTXC IS COMPILER SPECIFIC There are differences between C compilers RTXC built for a particular C compiler is
6. Quadros Systems Inc All Rights Reserved RTXC QUEUES QUEUE KERNEL SEVICES KS dequeue queue destination Get data from queue and store it at destination address RES dequeuew queue destination Same as KS dequeue but if queue is EMPTY wait until operation can be completed KS dequeuet queue destination ticks gt Same as KS dequeuew but duration of wait is limited by period defined by ticks Quadro Copyright O 2008 Quadros Systems Inc All Rights Reserved Systems Inc o RTXC QUEUES QUEUE KERNEL SEVICES ES enqueue queue source Put data at source address into queue KS enqueuew queue source Same as KS enqueue but if queue is FULL wait until there is room in queue to complete the operation KS enqueuet queue source ticks gt Same as KS enqueuew but limit duration of wait to period defined by ticks Quadro Copyright O 2008 Quadros Systems Inc All Rights Reserved Systems Inc o RTXC QUEUES QUEUE KERNEL SEVICES KS defqsema queue semaphore condition Associate semaphore with the given condition on queue KS defqueue queue width depth body count gt Define width depth queue body address and current size of queue KS inqqueue queue Get the number of entries currently in queue Ne purgequeue queue Purge queue of all entries Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved Systems Inc o R
7. cal prtsc comodry comidry conodry conidry prtdump Priority k 1 2 3 4 5 6 7 8 9 SE GO O n E O Stack Start FPU ak uL Dynamic Objects 0 System RAM 638 bytes User RAM ROM 5632 374 bytes Total System RAM 1006 bytes Total User RAM ROM 10952 626 bytes NUM 1 12 PM Quadr Copyright O 2008 Quadros Systems Inc All Rights Reserved Description RTAC Debugger Calendar TOD PrtSc Driver COM Output Driver COM Input Driver CONsole Output CONsole Input Screen dump PRN Driver Static Task 1 OS Systems Inc SYSgen ENERATING THE DEFINITION SOURCE CODE s RTXC System Generation C RTXC Examples demo E xercises demol demol rtx Edit View Marsa Window Help Information 49 Task Definition 3 2 3 4 5 6 7 8 9 H RTXCBUG CAL PRTSC COMODRU COMIDRU CONODRU CONIDRU PRTDUMP PRNDRU Priority AO CO rw O T E Go hM Entru rtxcbug cal prtsc comodru comidru conodru conidru prtdump Stack Start FPU uL Z Z Z Z Z Z Z Z Description RTAC Debugger Calendar TOD PrtSc Driver COM Output Driver COM Input Driver CONsole Output CONsole Input Screen dump PRN Driver Static Task 1 Dynamic Objects O System RAM 636 bytes User RAM ROM 5632 374 bytes Generate new source files Copyright O 2008 Quadros Systems Inc All Rights Reserved Quadros Systems Inc ss
8. e Allows interrupt servicing Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved ee RTXCbug MAIN MENU RTXCbug RTXC v3 7a xxxx vx x Date K o RTXC G Go to Multitasking Mode X Exit RTXCbug RTXCbug gt Copyright 2008 Quadros Systems Inc All Rights Reserved Quadros RTXCbug HELP MENU Tasks Mailboxes Partitions Queues Resources Semaphores Clock Timers Stack Limits Zero Partition Queue Resource Statistics Enter Task Manager Mode Task Registers Go to Multitasking Mode Return to Main Menu Exit RTXCbug z n bi D O DO K H Quadros Systems Inc Copyright O 2008 Quadros Systems Inc All Rights Reserved o RTXCbug SUMMARY Collects high water mark statistics Uses no resources until invoked Can be used to launch tasks individually to debug them The information collected may be used to redesign and re code the application Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved APPLICATION CODE Quadr Copyright O 2008 Quadros Systems Inc All Rights Reserved APPLICATION DEVELOPMENT PROCESS Doo Application Design SY Sgen Application Code RTXC Source Code Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved KERNEL SERVICES GENERAL CONVENTIONS Names begin with Ks format is KS verb n
9. PENDING state KS ingsema semaphore Get current state of semaphore Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved RTXCbug SEMAPHORE SNAPSHOT Semaphore Snapshot 1 2 3 4 gt 6 7 Name PRNSEMA ERISCOREM COMISEMA DEMOSEMO DEMOSEM1 DINTSEMA SDINSEMA state PEND DONE WAIT WAIT WAIT WAIT WAIT Waiter COMIDRV DEMO1 lt QNE gt DEMOO 1 lt MBXNE gt DEMOMBOX DINP DINP Semaphore States PEND WAIT DONE Pending Semaphore not yet set Waiting Tasks waiting for Semaphore Done Semaphore set but no tasks waiting Quadro Copyright O 2008 Quadros Systems Inc All Rights Reserved systems inc RTXC KERNEL OBJECTS TASKS for application functions MEMORY PARTITIONS for RAM memory management SEMAPHORES for event synchronization TIMERS for timed operations RESOURCES for exclusive access QUEUES for chronological data passing MAILBOXES and MESSAGES for message transmission Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC TIMERS TIME MANAGEMENT OBJECT Used for general purpose timing One shot and cyclic timers supported _ More than one timer per task permitted Time resolution dependent on system time base Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o TIMER OPERATION KS start timer T Initial period
10. performance f the time quantum is too large then critical events may be missed entirely Quadros PS Copyright O 2008 Quadros Systems Inc All Rights Reserved TIME SLICED SCHEDULING SUMMARY No task monopolizes the CPU 100 Non deterministic response to events Adjustable worse case response time obtained by changing the time quantum Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o ROUND ROBIN SCHEDULING System functions are organized into modules Individual task modules execute sequentially with or without time limit in one loop Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o ROUND ROBIN SCHEDULING mE d E GH II Each task runs until it terminates thus we have unequal CPU usage Quadros ight 2008 Quadros Systems Inc All Rights Reserved ROUND ROBIN SCHEDULING SUMMARY Application has 100 of CPU Modular design Unstable timing between successive passes of loop No consideration is given to relative importance of modules making event response time non predictable Quadros e Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC TRAINING UNIT 2 Application Development Process Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o APPLICATION USING RTXC Task 1 Task Task N at Cre Sa
11. 08 Quadros Systems Inc All Rights Reserved MESSAGE PASSING KS sendw e T amp MSG Message A Envelope MSGSEMA KS recelvew KS ack Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC MAILBOXES AND MESSAGES MESSAGE KERNEL SERVICES KS receive mailbox task Receive next message from any sender or from a specific sender defined by task in mailbox and return message address if mailbox is empty return NULL KS receivew mailbox task Same as KS receive but if mailbox empty wait until a message is sent DES receivet mailbox task ticks Same as KS receivew but period of waiting is limited by duration ticks KS message Acknowledge receipt and processing of message Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC MAILBOXES AND MESSAGES MESSAGE KERNEL SERVICES TKS send mailbox message priority semaphore Send message asynchronously at specified priority to mailbox and associate semaphore with acknowledgement signal KS sendw mailbox message priority semaphore Send message synchronously same as KS send but wait on semaphore for acknowledgement KS sendt mailbox message priority semaphore ticks Same as KS sendw but waiting period is limited by duration ticks KS defmboxsema mailbox semaphore Associate semaphore with the Not Empty condition of mailbox Quadros C
12. Copyright 2008 Quadros Systems Inc All Rights Reserved Systems Inc o RTXCbug TASK STATE DESCRIPTIONS The legitimate state descriptions are INACTIVE Not executing READY Active and ready to run READY Active but blocked by RTXCbug DELAY Blocked on a time delay SUSPENDED Suspended Semaphore Waiting on one or more events QueueEmpt y Waiting on an empty queue QueueFull Waiting on a full queue Mailbox Waiting on an empty mailbox Resource Waiting on a busy resource Partition Waiting on an empty partition Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXCbug STACK SNAPSHOT 77 RTXC Kernel 20 68 Task Size Used Spare 1 RTXCBUG 768 610 158 2 CLKDRV 212 122 390 2220 OZ 124 388 4 CONODRV 512 250 262 5 DEMO1 256 150 106 6 DINP Z00 210 16 186 Worst case interrupt nesting Worst case Signal List size Copyright O 2008 Quadros Systems Inc All Rights Reserved Quadros Systems Inc o RTXC KERNEL OBJECTS TASKS for application functions MEMORY PARTITIONS for RAM memory management SEMAPHORES for event synchronization TIMERS for timed operations RESOURCES for exclusive access QUEUES for chronological data passing MAILBOXES and MESSAGES for message transmission Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o RTXC MEMORY PARTITIONS RAM MEMORY MANAGEMENT OBJECT Prevents fragmentation of memo
13. ECT Supports multiple producers and multiple consumers Automatic synchronization possible on EMPTY and FULL conditions when using KS_enqueuew and KS_dequeuew Can be used with queue semaphores when trying to synchronize with multiple events using KS waitm e Not used when using KS enqueuew or KS dequeuew Use with multiple queues or with mailboxes or normal events _ Predefined WIDTH and DEPTH All entries in a queue have same Width e Different queues can have different Widths and Depths Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved v s FIFO QUEUE ORGANIZATION Queue Control Block Queue Body Width De oca Body Depth Eu meses Sema Sema Optional ONE Sema Width C2 G m D Gr CD H N D Waiters Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved PUTTING DATA INTO A QUEUE Use a variant of KS enqueue to put data into a queue e KS enqueuew or KS enqueuet Move data from a source area to the queue Source area should be at least size of queue s Width Give address of source area amp source as parameter to KS enqueue wlt Queue Source Area EN lt uu gt Width lt was Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved GETTING DATA FROM A QUEUE Use a variant of KS dequeue to get data from a queue e KS dequeuew or KS dequeu
14. G ROUTINES TRADITIONAL METHODOLOGY IRQ Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o RTXC INTERRUPT HANDLING RTXC METHODOLOGY IRQ TK Use C calling RTXC Prologue saves context convention provided In assembly code Interrupt Service Routine Corel Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved Systems Inc RTXC INTERRUPT HANDLING PROCESSING AN INTERRUPT Vector possible context switch Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o RTXC INTERRUPT HANDLING RIXC PROLOGUE RTXC switches stacks from the task stack to the system stack thus reducing the size of task stacks Saves interrupted context _ Interrupts are disabled while setting up contexts and processing interrupt nesting Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o E RTXC INTERRUPT HANDLING DEVICE HANDLER Written as a C function Argument is pointer to the stack frame of the interrupted process Processes the interrupt Can be interrupted by higher level interrupts Only those kernel services denoted by KS ISRxxx are allowed in the Device Handler Device Handler returns a frame pointer to the highest priority task so that the epilogue can restore that task s context Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved v s RTXC IN
15. ING to DONE as the result of a KS signal KS signalm KS ISRsignal KS ISRsignalm or possibly KS ISRexit Semaphore state 0x00 Transition from DONE to PENDING occurs as result of KS wait KS or KS waitm e Task does not wait Requesting task retains status as Current Task Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved v s WAITING STATE Event is expected but next occurrence has not yet happened Transition from PENDING to WAITING occurs as result of KS walt KS or KS waitm Atask is waiting on the event to occur Task Is blocked while waiting Semaphore state 0x01 OxFE Content of semaphore is the handle ID of the task waiting for the event Transition from WAITING to PENDING occurs a result of KS signal KS signalm KS ISRsignal KS ISRsignalm or possibly KS ISRexit Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved v s SEMAPHORE AND TASK COORDINATION Events can occur in two ways Before task attempts to synchronize with event using KS wait or KS waitm After task attempts to synchronize with event using KS wait or KS waitm KS na KS signal KS wait KS wait Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved ee SEMAPHORE STATE TRANSITIONS KS walt KS signal KS walt KS walt ERROR KS signal Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved e
16. Ope cd Copyright 2008 Quadros Systems Inc All Rights Reserved TASK CONTROL BLOCK Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved es READY LIST LINKAGE hipritsk TCB A NULL TCB NOE B na ds pritsk points to the current task Tasio Delta Task A Is the current task Note the use of the NULL task Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o READY LIST LINKAGE hipritsk Task B has preempted and is the current task TCB B TCB A NULL TCB TCB A m NULL TCB S PESE INC EMI Task Data Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC TASKS SHARING TASK CODE Quadros 24 Copyright O 2008 Quadros Systems Inc All Rights Reserved TASK KERNEL SERVICES A5 execurte Lask Make task READY for execution beginning at its starting address KS terminate task Terminate operation of task KS resume task Resume suspended task unless otherwise blocked Suspena task Suspend operation of task KS delay task ticks Block task for a period of time specified by ticks then unblock task when delay expires Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved dis TASK KERNEL SERVICES KS defpriority task priority Change the priority of task to priority KS Ingpriority task Get task s priorit
17. SYSgen ENERATING THE DEFINITION SOURCE CODE RTXC System Generation C RTXC Examples demo E xercises demol demol rtx File Edit View Project Window Help IAE 2 EE Generate Source Code 47 Task Definition _ Generate Project Source 1 RTXCBUG Classes Generate All 2 CAL Task 3 PRTSC Cancel COMODRU ST Semaphore ea 5 COMIDRU LT Queue Help TEO Mailbox 7 CONIDRU 8 PRIDUMP T Partition 9 PRNDRU amp Resource Dutput Directory C RTXC Examples demoiE xercises Dynamic Objects Total System RAM 1006 bytes Total User RAM ROM 10952 626 bytes NUM 1 21 PM Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved systeme Inc SYSgen MODULE NAMES xxxx TASK Task control block definitions SEMA Semaphore definitions RES Resource definitions MBOX Mailbox definitions QUEUE Queue definitions PART Memory Partition definitions CLOCK Clock definitions Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o SYSgen h files CTASK H define NTASKS 10 define DNTASKS 6 define RTXCBUG 1 CBUG debugger define CONAIDRV 2 Console A Input Task Zdefine CONAODRV 3 Console A Output Tas define CONBIDRV 4 Console B Input Task Zdefine CONBODRV 5 Console B Output Tas define EXAMPLEI 6 Example Task 1 Zdefine EXAMPLE2 7 Exa
18. TERRUPT HANDLING INTERRUPT SERVICE ROUTINE SERVICES KS ISRsignal semaphore Signal the given semaphore from an interrupt service routine KS ISRsignalm semaphore list Signal all semaphores in the semaphore list from the interrupt service routine DS ISRalloc map Allocate from an interrupt service routine a block of memory from map and return its address returns NULL if map is empty KS ISRexit frame semaphore Exit current interrupt service routine and optionally signal the given semaphore MES ISRtick void Perform RTXC required processing for a clock tick interrupt Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved Systems Inc ee ISRS S INTERRUPT SERVICE ROUTINE ASSEMBLY CODE Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved CLKDRV C FRAME clkc FRAME frame KS LSO lo neruda RS E S Creme Ss clock Rook s CO mo gt Setvect CLKINT isvccelk set interrupt level if needed Copyright 2008 Quadros Systems Inc All Rights Reserved UART C HANDLER AME comc FRAME frame unsigned char status status inp UART INT ID REG read hw status if status RX DATA READY RX is higher priority w in USART ichar inp UART RBR read char clear USART interrupt status inp UART INT ID REG re read hw st
19. TXCbug QUEUE SNAPSHOT E Queue Snapshot Name Current Depth Worst Count Waiters E CONIO 0 16 1 19 E CONOQ 108 1024 546 3413 3 COMOQ D 122 0 O COMODRV 4 DEMOQ 0 64 40 420 DEMOSEMO NE DEMO1 Queue Semaphore Condition Codes lt E gt Empty lt F gt Full lt NE gt Not Empty lt NF gt Not Full Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved Systems Inc o RTXC KERNEL OBJECTS TASKS for application functions MEMORY PARTITIONS for RAM memory management SEMAPHORES for event synchronization TIMERS for timed operations RESOURCES for exclusive access QUEUES for chronological data passing MAILBOXES and MESSAGES for message transmission Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o RTXC MAILBOXES MESSAGE INTERFACE BETWEEN TWO TASKS _ Mailboxes are defined globally Any task can send mail to any mailbox A task may use none one or many mailboxes Good design usually dictates one consumer Quadros 24 Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC MAILBOXES MAILBOX STRUCTURE Optional used for a multiple event wait Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved V A USING SEMAPHORES TO SERVICE MULTIPLE OBJECTS Cause semalist Mailbox 1 MBOXSEMA1 MBOXSEMAS 0 Waiters marh fen IE ED Mail
20. Tp recycle period expiration sema signal signal signal signal 71 SEMAPHORE Ay T R KS wait Quadros Systems Inc Copyright O 2008 Quadros Systems Inc All Rights Reserved o E ELAPSED TIME CALCULATION Lo 1 T KS elapse amp X KS elapse amp X KS elapse amp X X X X X T don t care T T T Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC TIMERS TIMER KERNEL SERVICES KS alloc timer void Allocate a timer block and return its address KS start timer timer period cyclic period semaphore gt Start timer giving it an initial period and an optional cyclic period and associate semaphore With the expiration of the initial period or cyclic period KS restart timer timer period cyclic period Reset and restart the active timer with a new initial period and an optional QUOI Et Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved systems inc RTXC TIMERS TIMER KERNEL SERVICES KS stop timer timer Stop the specified active timer and remove it from the active timer list KS free timer timer Free the timer block Me elapse counter Set current time into counter then subsequent call calculates elapsed time KS ingtimer timer Get the time remaining on an active timer Quadro Copyright O 2008 Quadros Systems Inc All Rights Reserved Syste
21. atus if status TX BUFF EMPTY KS ISRsignal OSEM signal char output semaphore outp PIC EOI ADDR EOI clear PIC interrupt return KS ISRexit frame ISEM signal char input semaphore else EN Transmit IRQ if status TX BUFF EMPTY status inp UART INT ID REG re read hw status if status RX DATA READY KS ISRsignal ISEM signal char input semaphore outp PIC EOI ADDR EOI clear PIC interrupt return KS ISRexit frame OSEM exit signalling char output sema outp PIC EOI ADDR EOI clear interrupt return KS ISRexit frame SEMA 0 Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved Systems Inc o SIMPLE DRIVER EXAMPLE SER OUT SER ENUSRSignal READ CW KS ISRSignal WRITE nes 7 INCHAR INSEMA KS wait KS dequeuew i io enqueue KS enqueuew ffe a it INQUEUE Application Task KS TT Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved systems Inc o E RTXC INTERRUPT HANDLING PRIVATE ISR The Interrupt Handler is outside the Kernel Prologue can save a short context for increased performance Can save stack switching logic if interrupts are disabled Service the IRQ _ Restore short context then decide what to do Could just return from interrupt fastest Or if ISR runs at Kernel Ceiling Leve
22. becomes ready it preempts the lower priority task and becomes the Current Task Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved v s E RTXC BASIC RULES The RTXC Kernel is interruptible but not reentrant nterrupt Service Routines may use only those services expressly intended for ISR usage he NULL Task is always the lowest priority task and its priority must never be changed The NULL Task must never be blocked Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved ee RTXC TASK SCHEDULING Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved PREEMPTIVE SCHEDULING SPECIFIC CHARACTERISTICS Tasks have priorities to indicate their relative importance Highest priority ready task gets control of processor asks execute in strict priority sequence with preemptive task scheduling Current Task runs until it terminates is preempted blocked or yields control task can control its own runtime by terminating blocking or yielding Preemption is handled by the Scheduler Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved v s PREEMPTIVE SCHEDULING REACTING TO AN EVENT EVENT Task A Blocks Task B continues Task B is preempted Task A runs An event can preempt and force another task to take control Quadros PREEMPTIVE SCHEDULING SUMMARY Most important ready
23. box 2 meuse KS waitm semalist Switch cause case MBOXSEMAL case MBOXSEMAZ MBOXSEMA2 Semaphore Mailbox 3 break MBOXSEMAS Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC MESSAGES PRIORITY DATA MOVEMENT OBJECT Data Is sent to a receiver via a mailbox Messages are inserted according to priority or FIFO if they have the same priority Messages are generally processed in the order of their priorities but a task can receive from a specified task if desired No data is moved only pointers Body of message is defined by user Message body can contain a response message from receiver Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved v s RTXC MESSAGES ENVELOPE Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved o RTXC MESSAGES Type A Message Envelope Copyright O 2008 Quadros Systems Inc All Rights Reserved B Message Envelope RAM or ROM Quadros 3 RTXC MESSAGES MAILBOX WITH MESSAGES Mailbox First Message Second Message M Meters Message SS SACS Envelope Envelope Semaphore 25 ee One dc A Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC MESSAGES MAILBOX WITH WAITERS Mailbox TCB X EGS Lado Semaphore Quadros Copyright O 20
24. brary librtxc lib Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved Systems Inc o APPLICATION DEVELOPMENT PROCESS Application Design sYSgen Application Code RTXC Source Code ss era gt p Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved SYSgen INTERACTIVE SYSTEM GENERATION UTILITY Predefinition of system configuration Produces C data structures for all kernel objects Uncomplicated and efficient definitions Fast turnaround of configuration changes Error free code of system configuration self documenting Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o SYSgen Creates rtx c and h files files used by SYSgen for configuration Cfiles allocate space and instantiate objects h files declare constants for the objects Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o SYSgen Kernel Object names integrated with C Header files Accessible to Application code e RTXCbug displays and dialog Consistent method of editing all Kernel Objects Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved o MAIN MENU NUM PM Copyright O 2008 Quadros Systems Inc All Rights Reserved SYSgen OPEN PROJECT RTXC Syste
25. called a BINDING Details of binding to a compiler are found in the Binding Manual Quadros we Copyright 2008 Quadros Systems Inc All Rights Reserved USER S MANUAL CONTENT Theory of Operation Section 2 Functional overview organization and content of RTXC kernel objects Section 3 Tutorial Section 4 RTXC Kernel Services reference Section 5 RTXCgen system configuration utility Section 6 Device drivers and interrupt service routines Section 7 RTXCbug system level debugging tool Section 8 Application notes Section 9 Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved v s RTXC KERNEL OBJECTS TASKS for application functions MEMORY PARTITIONS for RAM memory management SEMAPHORES for event synchronization TIMERS for timed operations RESOURCES for exclusive access QUEUES for chronological data passing MAILBOXES and MESSAGES for message transmission Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved v s MULTITASKING CHARACTERISTICS Formal structure is provided by policies and rules implemented as Kernel Services User s application is organized into a set of tasks Application Program Interface API provides a standard interface between application tasks and the kernel services Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved ee RTXC POLICIES AND RULES
26. d Ride e SYSgen TASK EDIT MENU s System Generation C RTAC Examples demo E xercises demol demot File View Project Window Help t Edit T ask Definition Ctrl C Insert Task Definition Insert Delete Task Definition Delete Append Task Definition Ctrl i Move Task Definition Ctrl M H Name Priority Entry Stack Start FPU Description RTACBUG 5 RINC Debugger Calendar TOD PrtSc Driver COM Output Driver COM Input Driver CONsole Output CONsole Input Screen dump PRN Driver Dynamic T asks Ctrl D A comodru comidru conodru conidru prtdump prndru 2 CO zw OUT E Go MN Tm de Dynamic Objects 0 System RAM 580 bytes User RAM ROM 5120 340 bytes Poo Total System RAM 948 bytes Total User RAM ROM 10440 592 bytes NUM 12 58 PM Quadros Systems Inc Copyright O 2008 Quadros Systems Inc All Rights Reserved SYSgen APPENDING A NEW TASK RTXC System Generation C RTAC Examples demo E xercises demol demo File View Project Window Help Edit Task Definition Ctrl C Insert Task Definition Insert Delete Task Definition Delete Append Task Definition i Move Task Definition Ctl amp M Ctrl D Dynamic Tasks a LR AT LRLELLIL LE Name Priority Stack Start FPU Description RTXCBUG RTXC Debugger CAL cal Cale
27. e SEMAPHORE STATE TRANSITIONS 5 KS pend KS signal KS walt KS pend KS pend y RS signal KS walt Copyright O 2008 Quadros Systems Inc All Rights Reserved KS signal KS walt ERROR SEMAPHORES AND APPLICATIONS Task 1 North South Light F I es Red Signal SEMA2 Wait Por Prom Task 2 Turn Light Green Wart a while with Fo adela 71 Copyright 2008 Quadros Systems Inc All Rights Reserved RTXC SEMAPHORES SEMAPHORE KERNEL SERVICES RS walt semaphore Cause task to wait for occurrence of event associated with semaphore RES waitt semaphore ticks Same as KS but duration of wait limited to a period defined by ticks KS waitm semaphore list Cause task to wait for occurrence of an event associated with any semaphore found in semaphore list logical OR condition and returns the ID of the semaphore associated with the event PKS signal semaphore gt Signal semaphore that associated event has occurred Quadro Copyright O 2008 Quadros Systems Inc All Rights Reserved Systems Inc ee RTXC SEMAPHORES SEMAPHORE KERNEL SERVICES K signalm semaphore list Signal multiple semaphores as specified in semaphore list that particular event has occurred KS pend semaphore Set semaphore to a PENDING state KS pendm semaphore list Set multiple semaphores as specified in semaphore list to a
28. e ownership of resource Quadro Copyright O 2008 Quadros Systems Inc All Rights Reserved systems inc RTXC RESOURCES RESOURCE KERNEL SERVICES KS defres resource resattr Enable or disable the priority inversion attribute for the resource KS ingres resource Get the identifier of the owner of a resource Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved RTXCbug RESOURCE SNAPSHOT Resource Snapshot Name Count Conflicts Owner Waiters 1 PRNRES 20742 1 2 DOSRES 2 PRTSCRN FILMGR Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC TRAINING COURSE PRACTICAL EXERCISES Exercise 5a Using Semaphores to Synchronize Tasks Exercise 6a Using Cyclic timers with semaphores Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved RTXC TRAINING UNIT 5 Queues Mailboxes and Messages Quadr Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC KERNEL OBJECTS TASKS for application functions MEMORY PARTITIONS for RAM memory management SEMAPHORES for event synchronization TIMERS for timed operations RESOURCES for exclusive access QUEUES for chronological data passing MAILBOXES and MESSAGES for message transmission Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved E RTXC FIFO QUEUES CHRONOLOGICAL DATA MOVEMENT OBJ
29. en e Defining a task and a resource Getting an application to run Observe dynamic task priorities Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o RTXC TRAINING UNIT 3 Tasks and Memory Partitions Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o RTXC KERNEL OBJECTS TASKS for application functions MEMORY PARTITIONS for RAM memory management SEMAPHORES for event synchronization TIMERS for timed operations RESOURCES for exclusive access QUEUES for chronological data passing MAILBOXES and MESSAGES for message transmission Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved GH RTXC TASKS FUNDAMENTAL PROGRAM MODULE Written as a C function void return and void arguments Can be instantiated dynamically or statically Usually performs a limited function Spark control Fuel injection etc Each task requires Its own stack Task priority defined at System Generation Task priority variable during runtime Task status and context automatically maintained by RTXC Scheduler Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved v s RTXC TASKS TWO FORMS RUN AND TERMINATE Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved o TWO FORMS RUN FOREVER vold taskname vold Delta re ni for 55 M bes
30. et Move data from queue to a destination area Destination area should be at least size of queue s Width Give address of destination area amp dest as parameter to KS dequeue wlt Queue Destination Area L e lt Width lt wan Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved E RTXC QUEUE SEMAPHORE USAGE Queue Not Empty EVENT Before Queue Empty After KS enqueue Queue Header Queue Body Queue Header Queue Body Queue Data Sema OF Sema ONF Sema ONE Sema ONF Sema Waiters Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC QUEUE SEMAPHORE USAGE Queue Empty EVENT Before Queue Not Empty After KS_dequeue lueue Header Queue Body Queue Header Queue Body Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved ee RTXC QUEUE SEMAPHORE USAGE Queue Full EVENT Before Queue Not Full After KS_enqueue Queue Header Queue Body Queue Header Queue Body Queue Data Sema Sema OF Sema ONE Sema ONE Sema ONF Sema ONF Sema Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved RTXC QUEUE SEMAPHORE USAGE Queue Not Full EVENT Before Queue Full After KS_dequeue Queue Header Queue Body Queue Header Queue Body Queue Data Sema Sema OF Sema ONE Sema ONE Sema ONF Sema Walters Quadros Copyright O 2008
31. iod of ticks E free map address gt Free the memory block at address to specified Memory Partition KS inqmap map Get the memory block size of map Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC MEMORY PARTITIONS PARTITION KERNEL SERVICES BAS alloc part void Allocate a dynamic Memory Partition control block and return its identifier returns NULL if none available KS defpart map address size number Define attributes of an existing or dynamically allocated partition map with a memory array located at address and containing number of blocks of size size KS create part address size number Allocate a dynamic Memory Partition at address containing size sized number of blocks combination of KS alloc part and KS defpart free part map gt Free the dynamically allocated Memory Partition whose identifier is map Quadro Copyright O 2008 Quadros Systems Inc All Rights Reserved Systems Inc o RTXCbug MEMORY PARTITION SNAPSHOT partition Snapshot Name Avail Total Worst Count Bytes Waiters 1 PRTSCMAP 27 4 1 0 2010 2 AIMAP 0 20 20 482 64 AINP Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC TRAINING COURSE PRACTICAL EXERCISES Exercise 2 Defining a Second static task Using Suspend and Resume to synchronize two tasks Exercise 3a Simulate a crude traffic light Suspend and Res
32. l enter the regular RTXC ISR form starting with a prologue use this to inform a kernel entity that an action needs to be taken Quadros BH Copyright 2008 Quadros Systems Inc All Rights Reserved RTXC INTERRUPT HANDLING A PRIVATE INTERRUPT AT KCL Interrupt Service Routine Vector Table Yes possible context switch 0 Kernel Ceiling Level Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC Real Time Executive in C Thank you Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved Systems Inc o
33. m Generation View Project window Help New i pen 2652 Save AS Importe Print Setup Exit Open an existing project file Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved Systems Inc o Total System 948 bytes Total User RAM ROM 10440 592 bytes NUM 12 46 Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved Systems Inc o SYSgen EDIT MENU os RTAC ao Generation C NR TXC Examples demo E xercises demol demol ta File EH view Project Window Help t Edit Task Definition Ctrl C Insert Task Definition Insert Delete Task Definition Delete Append Task Definition Move Task Definition Ctrl M Dynamic T asks Ctrl D Total System RAM 948 bytes TotalUser RAM ROM 10440 592 bytes NUM 12 48 PM Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved Systems Inc o SYSgen VIEW MENU lt lt RTXC System Generation C RTXC Examples demo E xercisesidemo1idemol rtx File Edit Project Window Help E Toobar Memory Usage Tasks Semaphores Queues Mailboxes Partitions Resources Total System 948 bytes TotalUserPAM ROM 10440 592 bytes NUM 12 50 PM Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved Systems Inc o Total System RAM 948 bytes gt TotalUserRAM ROM 10440 592 bytes NUM 12 51 PM
34. mple Task 2 define FPUTASKI 8 Floating Point Task Zdefine FPUTASK2 9 Floating Point Task define TASK1 10 Task Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved Systems Inc o SYSgen SUMMARY For best results follow this procedure Open a project file Edit make the changes to the kernel objects Save save the project file information Generate generate the source code c and h files Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXCbug SYSTEM LEVEL DEBUG FACILITY Quadros APPLICATION DEVELOPMENT PROCESS Doo Application Design SY Sgen Application Code RTXC Source Code RTXC Source Code Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXCbug SYSTEM LEVEL DEBUG FACILITY Symbolic system level inquiry display and control nvoked manually or via a program Provides coherent snapshots of internal system elements Limited task control capabilities Symbolic element names used for displays and dialog Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved es E RTXCbug User defined debug console device via RTXCgen System console Serial port Operates as a task usually highest priority Uses no system resources until invoked Freezes active timers Blocks all tasks except the debug console driver
35. ms Inc o RTXCbug CLOCK SNAPSHOT Clock Snapshot lock rate is 100 Hz Tick interval is 10 ms Maximum of 16 timers mek timer is 37046 ET is 126 ticks RTC time is 370 Time Cyclic Task Timer Object Remaining Value Name Type Name 500 1000 CAL Timer CALSEMA 7500 0 Delay TACHI Quadro Copyright O 2008 Quadros Systems Inc All Rights Reserved Systems Inc o RTXC KERNEL OBJECTS TASKS for application functions MEMORY PARTITIONS for RAM memory management SEMAPHORES for event synchronization TIMERS for timed operations RESOURCES for exclusive access QUEUES for chronological data passing MAILBOXES and MESSAGES for message transmission Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC RESOURCES EXCLUSIVE ACCESS OBJECT Resource may be any entity Hardware or Software Resource permits exclusive access to entity by owner One owner at a time Priority inversion optionally handled by RTXC RT XC manages tasks waiting to become resource owner Caution Nested ownership is allowed make sure you match KS locks and KS unlocks Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved ee RTXC RESOURCES RESOURCE MANAGEMENT KS lock Ro LOCK Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o RTXC RESOURCES PRIORITY INVERSION Task
36. ndar TOD PRTSC prtsc PrtSc Driver COMODRU comodru COM Output Driver COMIDRU comidru COM Input Driver CONODRU conodru CONsole Output CONIDRU conidru CONsole Input PRTDUMP prtdump Screen dump PRNDRU prndru PRN Driver rz C uU E C2 N de Z Dynamic Objects System RAM 580 bytes User RAM ROM 5120 340 bytes Quadros Copyright 2008 Quadros Systems Inc All Rights Reserved SYSgen 49 Task Definition 2 3 4 5 6 7 8 9 Dynamic Objects O CAL PRTSC COMODRU COMIDRU CONODRU CONIDRU PRTDUMP PRNDRU NEW TASK Priori O DD zl C Vi E GO 49 Task Object Definition ription Name TASK1 er Priority 2 EIU Sc Driver Output Driver Entry task p Input Driver Stack Size 51 2 Starting Order 2 bytes E Driver Description Static Task 1 System RAM 580 bytes User RAM ROM 5120 340 bytes Total System RAM 948 bytes Total User RAM ROM 10440 592 bytes NUM 2 04 PM Copyright O 2008 Quadros Systems Inc All Rights Reserved Quadr Systems Inc e SYSgen TASK DEFINITION WINDOW K RTXC System Generation C RTXC Examples demoi E xercises demoldemol File Edit View Project Window Help T Task Definition 1 RTXCBUG CAL PRTSC COMODRU COMIDRU CONODRU CONIDRU PRTDUMP PRNDRU TASK1 L Entry rtxcbug
37. opyright 2008 Quadros Systems Inc All Rights Reserved Systems Inc ee RTXCbug MAILBOX SNAPSHOT E Mailbox Snapshot Name Current Count Waiters 1 FSRVMBOX O 31472 FILESRVR 2 PRNMBOX 0 3 20 PRNDRV 3 DEMOMBOX 0 450 Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC SPECIAL KERNEL SERVICES RTXC SPECIAL DIRECTIVES KS deftime systime Define the current date and time in elapsed seconds from base systime January 1 1970 KS inqtime voig Get the current date and time expressed as elapsed seconds from base system time January 1 1970 KS nop void Test service no operation KS user function argument list User defined function is called by the standard RTXC KS protocol and argument list passed to it Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved Systems Inc o RTXC TRAINING COURSE PRACTICAL EXERCISES Exercise 7 Passing information between tasks using Queues Exercise 8 Use Mailboxes and duplicate the functionality of exercise 7 Exercise 9 Create an application that will wait on multiple events Use RT XCbug to view the current state of the application Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved ee RTXC TRAINING UNIT 6 Interrupt Handling Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o INTERRUPT HANDLIN
38. oun suffix object Suffixes example KS sendw KS sendt KS waitm w unconditionally waits gt t waits with timeout values m waits on multiple task argument of O means Current Task def services define inq services inquire example KS defpriority KS inqpriority Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC TIME All time is measured in units called ticks The duration of 1 tick depends on the frequency of the system interval timer Units of ticks are milliseconds he smallest tick duration supported by RTXCgen is 1 ms The file cclock h defines the duration of 1 tick with the constant CLKTICK To convert from real time to system time express real time in ms and divide by CLKTICK 5 sec 5000 ms 5000 CLKTICK Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved v s INACCURACIES WITH SINGLE TICK DURATIONS Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o APPLICATION CODE SUMMARY Consists of C source files Can have multiple modules Will interact with files generated by SYSgen Must include those SYSgen h files needed Use Kernel Service calls to manipulate Kernel Objects Links with RTXC library Quadros e Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC TRAINING COURSE PRACTICAL EXERCISES _ Exercise 1 e Familiarization with SYSg
39. ry Many Memory Partitions may be defined Also known as Memory Array Partitions MAPs Memory Partitions may be defined statically and or dynamically Memory Partitions defined globally Any task may allocate memory from any Memory Partition Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved ee RTXC MEMORY PARTITIONS MEMORY PARTITION ORGANIZATION Partition Partition Header Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved ef e RTXC MEMORY PARTITIONS SUBDIVISION OF PARTITIONS Partition with two blocks of size 1024 Partition with two blocks of size 512 Partition with two blocks of size 256 Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC MEMORY PARTITIONS AVOIDING FRAGMENTATION IN THE HEAP malloc DE Et Fragmented Space cannot allocate memory of size 1 KS 0 KSfree J Since blocks the same size we perfect fit Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o RTXC MEMORY PARTITIONS PARTITION KERNEL SERVICES alloc map Allocate a block of memory from map and return its address returns NULL if partition is empty allocw map gt Same as alloc but if map is empty wait until memory available RES alloct map ticks Same as allocw but limit duration of wait to a per
40. task at any given time controls the CPU Synchronized with events through the use of task priorities A deterministic design is possible because response time to an event is predictable Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o TIME SLICED SCHEDULING SPECIFIC CHARACTERISTICS No task monopolizes CPU because execution time is limited by a time quantum Granularity of time quantum determines system responsiveness Process must be predictable so that time quantum can be chosen correctly Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved o TIME SLICED SCHEDULING 5 en m E mm mm e Time Qua Quadros Systems Inc TIME SLICED SCHEDULING NON DETERMINISTIC RESPONSE TIME EVENT EVENT Task B handles the event Time gt LJ Response Time to Response Time to first event second event Quadros ight 2008 Quadros Systems Inc All Rights Reserved TIME SLICED SCHEDULING FARGE TIME QUANTUM MISSING AN EVENT Task B handles the event EVENT EVENT Task B only recognises one of the events Quadros ight 2008 Quadros Systems Inc All Rights Reserved TIME SLICED SCHEDULING TIME QUANTUM CAUTION There is an overhead associated with each task switch If the time quantum is too small then the overhead may become excessive and lead to undesirable system
41. ume tasks Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC TRAINING UNIT 4 Semaphores Timers and Resources Quadr Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC KERNEL OBJECTS TASKS for application functions MEMORY PARTITIONS for RAM memory management SEMAPHORES for event synchronization TIMERS for timed operations RESOURCES for exclusive access QUEUES for chronological data passing MAILBOXES and MESSAGES for message transmission Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved RTXC SEMAPHORES EVENT SYNCHRONIZATION OBJECT Associated with process or software generated events _ Tri state model PENDING WAITING or DONE State automatically maintained by RTXC Only one task can wait on a semaphore Multiple semaphores can be associated with one event Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved ee PENDING STATE Event is expected but next occurrence has not yet happened No task is waiting on the event to occur All semaphores set to PENDING state by default during system initialization Semaphore state OxFF assuming a character sized definition of type SEMA Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved ee DONE STATE Expected event occurred but no task was waiting for it Transitions from PEND
42. y Ro 50010015005 52025 Define a task s time slice time quantum KS Ingslice task gt Get task s time slice time quantum KS yield vold gt Yield control of the CPU to another task used with round robin scheduling Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved systems inc TASK KERNEL SERVICES KS alloc task void gt Allocate a TCB from the pool of dynamic TCBs KS deltask Lask priority Stack Stack Size entry Define attributes of task 1250 255 aro task eNVOESg Define the environment arguments of task KS ingtask arg task Get address of task s environment arguments Quadros Copyright O 2008 Quadros Systems Inc All Rights Reserved Systems Inc o TASK KERNEL SERVICES KS ingtask void Get task number of Current Task KS block start end Blocks range of tasks from start to end KS unblock start end Unblocks range of tasks from start to end Quadros Systems Inc Copyright O 2008 Quadros Systems Inc All Rights Reserved o RTXCbug TASK INFORMATION se Task Snapshot Name RTXCBUG PRISE CONODRV CONIDRV HISTASK COMODRV DINP DEMO1 1 W FF 1 2 9 8 12 10 11 14 Scale READY READY READY QueueEmpty CONIQ INACTIVE QueueEmpty COMOO Semaphore DINTSEMA SDINSEMA Semaphore DEMOSEMO lt QNE gt DEMOO DEMOSEM2 lt MBXNE gt DEMOMBOX Quadros
Download Pdf Manuals
Related Search
Related Contents
Le sommaire - Gazette des communes TAFCO WINDOWS NU2-340V-W Installation Guide 110493811010 Emerson 99 Series Commercial/Industrial Regulators Drawings & Schematics Belkin 25PB082 User's Manual Automates RapidLab 1260 et RapidLab 1265 – Siemens Envizen V7028D 4GB Black tablet Guía de Automatrícula Miele KM 6387 PowerFlex User Manual Copyright © All rights reserved.
Failed to retrieve file