Download presentation
Presentation is loading. Please wait.
Published byWillis Poole Modified over 9 years ago
2
RTX - 51
3
Objectives Resources needed Architecture Components of RTX-51 - Task - Memory pools - Mail box - Signals
4
Resources Needed RTX - 51 requires the following 8051 system resources: Code memory: - Approx. 6 to 8 KB of memory. Internal (Data & IData) RAM: - 40 to 46 bytes for system data. - 20 to 200 bytes for stack. - Register bank 0 for standard tasks. - Register banks 1,2,3 for fast tasks.
5
System ISRs Application ISRs Application Tasks System Tasks Architecture Of RTX 51 Scheduler Int. Handler Dispatcher Kernel
6
External (XDATA) RAM: - Minimum of 450 bytes. Timer 0 or 1 for system clock.
7
Components of RTX - 51 Task Management Memory Management * Memory pools Intertask Communication * Mail-Box Intertask Synchronization * Signals * Semaphores
8
Scheduler Dispatcher Task Management
9
* Scheduler Task Classification Standard Tasks Fast Tasks
10
Task Classes : 1) Standard tasks: - More time for task switching. - Share common stack and register bank. - Register bank 0. - Interrupted by fast tasks. - Interrupt themselves mutually. - Contains context area in external memory - Maximum of 16 standard tasks. - Priorities 0,1,2.
11
. 2) Fast tasks: - Short responses. - Contains separate register bank and stack area. - Register banks 1,2,3 - Contains highest priority(3) & can therefore interrupt standard tasks. - Cannot mutually interrupt. - Maximum of 3 fast tasks can be active in system.
12
Scheduling Algorithms 1) Cooperative(or)Round-robin: - Process currently running must give up CPU time slices to other processes. - Application must have special code loop that yields control to allow other application to execute. - When fails to yield, it “hogs” the CPU. - Ex: Macintosh, Win3.X 2) Preemptive: - OS schedules CPU time and an application can be preempted by OS at any time. - Ex: Win95, WinNT, Unix.
13
Ready Sleeping RunningBlocked Task State Diagram
14
Task States : READY: - All tasks which can run are READY.One of these tasks is the RUNNING task. RUNNING: - Task which is currently being executed by processor. - Only one task can be in this state at a time BLOCKED: - Task waits for an event.
15
SLEEPING: - All tasks which were not started or which have terminated themselves are in this state. By default preemption method is used in RTX-51
16
Task1 Initialize Function to be performed Function to be performed System call: wait for an event System call: wait for an event Task2 Initialize Function to be performed Function to be performed System call: delete itself System call: delete itself Stop Task Layout Task Layout
17
-Task1 has to perform certain action each time an event occurs.After completion it will wait for a new event. - Task2 after performing one event, will delete itself. Ex:Self-test-has to be executed once at every power-up.
18
Stack-Area for Normal task Stack Area for Fast Task 3 Stack Area for Fast Task 2 Stack Area for Fast Task 1 Reg. bank 3 for Fast Task3 Reg. bank 2 for Fast Task 2 Reg. bank 1 for Fast Task 1 Reg.bank 0 for Normal Tasks Normal-Task Context Normal-Task Context Normal-Task Context Switching of Dispatcher
19
Task Management Services offered by task management are: * To start and initialize system.(os_start_system) * To declare a task. * To create a task(os_create_task) * To delete a task(os_delete_task)
20
To Initialize and start the system: signed char os_start_system(unsigned char task_id) - task_id identifies first task to be started. - During this command following steps will take place: * disable all interrupts * clear memory space * initialize system clock hardware * creation of first user task * initialize interrupt hardware * enable interrupts * start dispatcher
21
To declare a Task : void func(void) _task_ _priority_ - func. is variable name for task to be declared. - Cannot return a value. - No parameter values are passed. - ranges from 0…255.Maximum of 256 tasks can be defined. - Only 19 tasks can be active at a time. - Declare task will reside in SLEEPING state.
22
1) Task Management (a) To create a task: signed char os_create_task(unsigned char task_id) - task_id identifies task to be started. - starts a function defined with C51 attribute _task_ as RTX-51 task. - task is placed in list of READY tasks. (b) To delete a task: signed char os_delete_task(unsigned char task_id)
23
- task_id identifies task to be deleted. - Only created task can be deleted. (c ) To determine running task_id: signed char os_running_task_id(void) - Number of the task currently being executed by the processor is returned. - Task number corresponds to number used in task declaration(0…255).
24
1) Memory Management Services offered by memory management are: * To generate memory pool(os_create_pool) * To request memory block from pool(os_get_block) * To return memory block to pool(os_free_block)
25
- Dynamic memory space is desired for storing intermediate results. - 16 memory pools - 255 memory blocks in each pool Functions supported are : (a) Generate memory pool : signed char os_create_pool(unsigned int block_size,void xdata *memory, unsigned int mem_size)
26
-block size defines usable size of individual blocks.only one pool can be defined per block size. -*memory designs start address of memory area to be managed. -mem_size designs size of area. -Pools with various block sizes. -Pool is stored and managed in XDATA area. (b) Request memory block from pool: void xdata os_get_block(unsigned int block_size) -block size defines usable size of individual blocks.only one pool can be defined per block size. -*memory designs start address of memory area to be managed. -mem_size designs size of area. -Pools with various block sizes. -Pool is stored and managed in XDATA area. (b) Request memory block from pool: void xdata os_get_block(unsigned int block_size)
27
- gets memory block from memory pool referenced by block size. - block_size is desired block size.pool with blocks of required size must exist. (c ) Return memory block to pool: signed char os_free_block(unsigned int block_size, void xdata *block) - returns memory block to associated pool. - block designates returned block. - gets memory block from memory pool referenced by block size. - block_size is desired block size.pool with blocks of required size must exist. (c ) Return memory block to pool: signed char os_free_block(unsigned int block_size, void xdata *block) - returns memory block to associated pool. - block designates returned block.
28
3) Intertask Communication Services offered by memory management are: * To send a message(os_send_message) * To read a message(os_wait)
29
* Mailboxes : -Messages can be exchanged free of conflicts between individual tasks. -Fixed number of 8 mailboxes.(0…7) -Messages can be exchanged in words (2 bytes). -Identified with a mailbox number. -Freely used by all tasks. * Mailboxes : -Messages can be exchanged free of conflicts between individual tasks. -Fixed number of 8 mailboxes.(0…7) -Messages can be exchanged in words (2 bytes). -Identified with a mailbox number. -Freely used by all tasks.
30
Functions supported are: (a) Send a message: signed char os_send_message(unsigned char mailbox,unsigned int message,unsigned char timeout) -mailbox is identification of mailbox. -message is 2-byte value. -timeout is time limit for wait time for a full message. (b) Read a message: signed char os_wait(unsigned char event_selector, unsigned char timer_ticks, unsigned int xdata *message) Functions supported are: (a) Send a message: signed char os_send_message(unsigned char mailbox,unsigned int message,unsigned char timeout) -mailbox is identification of mailbox. -message is 2-byte value. -timeout is time limit for wait time for a full message. (b) Read a message: signed char os_wait(unsigned char event_selector, unsigned char timer_ticks, unsigned int xdata *message)
31
- event_selector = event1+event2..specifies the events which are to be waited for. Ex: K_MBX+mailbox number. - selects mail-box from which message is to be received. - timer_ticks determines number of system intervals to occur until time_out event occurs, if K_TMO was specified. ! must be 0 if no wait. ! 255 for endless waiting. - event_selector = event1+event2..specifies the events which are to be waited for. Ex: K_MBX+mailbox number. - selects mail-box from which message is to be received. - timer_ticks determines number of system intervals to occur until time_out event occurs, if K_TMO was specified. ! must be 0 if no wait. ! 255 for endless waiting.
32
3) Inter task synchronization Services offered by memory management are: * Signals - To send a signal(os_send_signal) - To wait for a signal(os_wait) - To clear a signal(os_clear_signal) * Semaphores - Wait for a token(os_wait) - Send a token(os_send_token)
33
* Signals : - Used when task synchronization is required without data exchange. Functions supported are: (a) send a signal: signed char os_send_signal(unsigned chartask_id) - task_id is where signal is to be sent. - if task is already waiting,it is made READY. - Otherwise signal is stored in signal flag. * Signals : - Used when task synchronization is required without data exchange. Functions supported are: (a) send a signal: signed char os_send_signal(unsigned chartask_id) - task_id is where signal is to be sent. - if task is already waiting,it is made READY. - Otherwise signal is stored in signal flag.
34
(b) Wait for a signal: os_wait(K_SIG, timer_ticks, 0) - Since there is no data transfer denote message as 0. (c ) Clear a signal: signed char os_clear_signal(unsigned char task_id) - task_id denotes the task whose signal flag is to be cleared. * Semaphores : - Used to control access to shared resources. - resources can be shared free of conflicts. (b) Wait for a signal: os_wait(K_SIG, timer_ticks, 0) - Since there is no data transfer denote message as 0. (c ) Clear a signal: signed char os_clear_signal(unsigned char task_id) - task_id denotes the task whose signal flag is to be cleared. * Semaphores : - Used to control access to shared resources. - resources can be shared free of conflicts.
35
Functions supported are: (a) Wait for a token: os_wait(K_MBX+sem.no., timer_ticks, 0) - Semaphore number ranges from 8…15. - Since no data transfer, message is 0. - Task requesting a resource controlled by semaphore can obtain a token from this. this semaphore. - If token is available, task will continue its execution. (b) Send a token: signed char os_send_token(unsigned char semaphore) Functions supported are: (a) Wait for a token: os_wait(K_MBX+sem.no., timer_ticks, 0) - Semaphore number ranges from 8…15. - Since no data transfer, message is 0. - Task requesting a resource controlled by semaphore can obtain a token from this. this semaphore. - If token is available, task will continue its execution. (b) Send a token: signed char os_send_token(unsigned char semaphore)
36
- semaphore is the number of desired semaphore. - After completing its operation, a task will return related token to semaphore. System clock Management : (a) To set system time interval: signed char os_set_slice(unsigned int timeslice) - timeslice defines time interval in number of processor cycles.Permissible values are 1000…40000. - default time interval is 20000. - semaphore is the number of desired semaphore. - After completing its operation, a task will return related token to semaphore. System clock Management : (a) To set system time interval: signed char os_set_slice(unsigned int timeslice) - timeslice defines time interval in number of processor cycles.Permissible values are 1000…40000. - default time interval is 20000.
37
(b) To wait for time-out: os_wait( K_TMO, timer-ticks, 0) - K_TMO is event selector. - System will wait for time_out.If ticks is 0, then no wait for time_out. If 255, then endless waiting. (b) To wait for time-out: os_wait( K_TMO, timer-ticks, 0) - K_TMO is event selector. - System will wait for time_out.If ticks is 0, then no wait for time_out. If 255, then endless waiting.
38
Interrupt Management Services offered by memory management are: * To assign an interrupt to calling task(os_attach_interrupt) * To detach interrupt(os_detach_interrupt) * To enable interrupt(os_enable_isr) * To disable interrupt(os_disable_isr)
39
(a) To attach interrupt : signed char os_attach_interrupt(unsigned char interrupt) - interrupt designates vector number of interrupt source.(values are 0….31) - Assigns an interrupt source to calling task. - each interrupt source cannot be assigned to more than one task. - several interrupt source can be assigned to one task. (a) To attach interrupt : signed char os_attach_interrupt(unsigned char interrupt) - interrupt designates vector number of interrupt source.(values are 0….31) - Assigns an interrupt source to calling task. - each interrupt source cannot be assigned to more than one task. - several interrupt source can be assigned to one task.
40
(b) To detach interrupt : signed char os_detach_interrupt(unsigned char interrupt) - interrupt designates vector number of interrupt source.(values are 0….31) - Cancels the assignment of interrupt source to calling task. (b) To detach interrupt : signed char os_detach_interrupt(unsigned char interrupt) - interrupt designates vector number of interrupt source.(values are 0….31) - Cancels the assignment of interrupt source to calling task.
41
(c) To enable interrupt source : signed char os_enable_isr(unsigned char interrupt) - interrupt designates vector number of interrupt source assigned to.(values are 0….31) - Enables an interrupt source which is assigned to interrupt function.
42
(d) To disable interrupt source : signed char os_disable_isr(unsigned char interrupt) - interrupt designates vector number of interrupt source assigned to.(values are 0….31) - Disables an interrupt source which is assigned to interrupt function.
43
End Of The Session!
44
Thank You!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.