TI Real-time operating system Sys/bios Usage Summary

Source: Internet
Author: User

1: Overview:

The Sys/bios is a scalable, real-time operating system. With very fast response times (short delays in interrupts and task transitions), deterministic response times, robust preemption systems, optimized memory allocation and stack management (minimizing consumption and fragmentation). The system can be modular and can be cropped.

The biggest feature is: real-time.

2:xdctools:

Xdctools is a real-time software component Technology (RTSC) referenced by Sys/bios, which includes a number of useful tools, standard API functions, static configuration files, and packaging (packaging) operations. The main highlight of XDC is that it standardizes the delivery process and simplifies the process of referencing other packages under the target platform in the application.

When the project is created, a RTST-based platform is created to allocate and manage the memory and cache, which automatically generates the corresponding CMD file. The process is created as follows: (based on TI DM6437 platform)



3: Creation of the Sys/bios project based on the RTSC platform:




4: Four Kinds of threads

A thread is a set of code that is stored in memory, and once the register is properly initialized, the CPU executes the code. Threads can be of any type, Sys/bios defines four types of threads:

Hardware interrupts (HWI), software interrupts (SWI), Tasks (Task), free (idle).

Hardware interrupts: The most stringent time requirements, the task of real-time response: generally peripheral and internal real time and Timer module (timer module is implemented by hardware interrupt, using hardware timer).

Software interruption: A middle thread that has a low time requirement. (The clock module is a timer module based on the software interrupt module)

Task: The CPU executes the main thread, and the difference between software interrupts can be blocked (can wait)

Idle: Lowest Priority

Cheng and display priority for each line: the implicit priority is determined by the type of thread, the display priority is determined by the programmer of the software, and the preemption is allowed: the thread with the highest priority is able to grab the thread with the lower priority, prioritize the execution, This higher priority scheduling management mechanism ensures that the highest priority threads can be executed at the first time. The following are the preemption of threads:


5: Component Configuration CCS provides a way to configure two components, a graphical configuration method that users can click to add the appropriate module:


Another way to do this is by manually editing the. cfg file, which is written in the JavaScript language and can also be configured with components.

6: Thread creation and configuration

Sys/bios is created and configured in two ways in terms of thread creation and configuration, one that is static and created by Xdctools. One is the creation of dynamic, is created in the program, the following is hwi as a routine, listed separately; two ways to create:

Static creation: Can be configured through a graphical interface, or manually written. cfg files in JavaScript scripting language, write the manual. cfg file configuration hwi:

var hwi0params =new Hwi.params ();

Hwi0params.instance.name= "Uart_handle";

Hwi0params.eventid= 85;

Program.global.uart_handle= Hwi.create (8, "&int_uart1isr", hwi0params);

Dynamic configuration: Configuring in a program

header files that need to be referenced

#include <ti/sysybios/hal/Hwi.h>

Hwi_handleuart_handle;

Hwi_paramshwi0params;

Error_block EB;

Error_init (&EB);

Hwi_params_init (&hwi0params);

Hwi0params.eventid = 85;

Uart_handle =hwi_craete (8, "&int_uart1isr", & Hwi0params, &eb);

7: Scheduling of tasks

The Sys/bios task thread has 0-31 priority (default 0-15, priority 0 is used by the idle thread and the task has a lowest priority of 1), but the number of tasks created can be unlimited without the memory allowed. The Sys/bios has a separate memory stack that can be suspended waiting for an event to occur, and the task will be interrupted by other higher-priority threads. The number and status can be changed dynamically when the program executes, and the priority can be dynamically modified.

The idle thread is a non-real-time thread, and all idle threads run on the same thread, and can be preempted by other threads at any time, by default using the task stack, if the task thread is disabled using the system stack, and only if no other thread (the Hwi/swi/task run time) runs , every idle thread function starts from execution to completion. All functions are executed and then executed from the first function.


8: Semaphore

Semaphores are typically used to coordinate access to shared resources between some competing tasks. The task can be suspended to wait for a particular event, only when the event is published to continue to perform the task, which is achieved through the semaphore, and the semaphore operation has two main operations: one is post, the other is pend, and these two actions are used to change the semaphore count value, The semaphore in Sys/bios has two modes of counting, one is counting in 2 binary mode and the other is counting mode. The value of the semaphore is 0 when the task is in a suspended state and the semaphore is 1 when the task resume resumes execution. The following are the differences between the two counting modes:

Operation (assuming a count initial value of 0)

Binary

Count

Semaphore_post () SEM);

1

1

Semaphore_pend () SEM);

0

0

Semaphore_post () SEM);

1

1

Semaphore_post () SEM);

1

2

Count

Task status

Semaphore_pend () SEM);

0

Hang Up

Semaphore_post () SEM);

>1

Recovery

Semaphore creation: The same two ways, statically created and dynamically created, to write a dynamically created routine:

Error_block EB;

Error_init (&EB);

Semaphore_params_init (&semparams);

Semparams.mode =semaphore_mode_binary;

Semparams.event = evt;

Semparams.eventid =event_id_00;

SEM = semaphore_create (1,&semparams, &eb);

if (SEM = = NULL)

{

System_abort ("Semaphore create failed");

}

Else

{

system_printf ("Semaphore Create is ok\n");

}

9: Mailbox

The mailbox Sys/bios system is used for buffer transfer between tasks, the size of the transport buffer is configured when the mailbox is created, the Mailbox_post () function completes the delegate, and the mailbox buffer has been transferred to the buffer when the Mailbox_pend () is executed , the data is obtained from the buffer.

Mailbox creation: Mailbox_handlemailbox_create (Sizet bufsize,

UInt Numbufs,

Mailbox_params *params,

Error_block *eb)

Void Mailbox_delete (Mailbox_handle*handle);

Mailbox_pend () is used to read from the mailbox Bufferde, if the mailbox does not have buffer in the time to wait for timeout;

Bool mailbox_pend (Mailbox_handle Handle,

Ptr buf,

UInt timeout);

Mailbox_post () is used to deposit buffer to the mailbox, if the mailbox is full, then wait timeout time;

Bool Mailbox_post (Mailbox_handle Handle,

Ptr buf,

UInt timeout);

10: Event

Events also provide a way to communicate and synchronize between threads, which has the same place as semaphores, and different places where events allow you to specify conditions for multiple tasks to wait.

Like Semaphores, the suspend and release of events is also achieved through Event_pend (), Event_post (), if an event is suspended and released, then it is the same as the semaphore, an event module is created that can manage 32 events, managed by the event ID, And each event is quite a semaphore.

The parameters of the Event_pend () function have a "andmask" and a "ormask". Andmask corresponds to a pending state where all events are required to be released in order to dismiss a task, and Ormask is a release of any event that can lift the suspended state of the task.

The same event_pend () also has a wait time parameter, and the function and semaphore are the same.

Here is a routine to create an event:

Event_handlemyevent;

Error_block EB;

Error_init (&EB);

/* Defaultinstance Configuration params */

MyEvent =event_create (NULL, &eb);

if (MyEvent ==null) {

System_abort ("EventCreate failed");

}

Suspend the event:

Uintevent_pend (Event_handle Event,

UInt Andmask,

UInt Ormask,

UInt timeout);

Release of the event:

Voidevent_post (Event_handle Event,

UInt eventids);

11: Problem Record

1: semaphores and mailboxes can be programmed into events

The semaphore and the mailbox can be programmed into an event, and when the semaphore and the mailbox are created, the ID of the event is written, and when the semaphore or the mailbox is released, it is equal to the event ID's publication.

2: Configuration of the task stack:

Each task can be configured with a separate stack size, which is configured when the task is created. The stack is too small to cause task creation to fail.

The relationship between 3:i-rtoskernel RTSC and Xdctools

Ti-rtos kernel refers to the Sys/bios real-time operating system developed by TI Company.

RTSC is a real-time software component platform that is based on this RTSC to create Sys/bios

Xdctools is a tool that relies on the RTSC platform configuration

Ti-rtos kernel is a system, RTSC is a platform, Xdctools is a tool.

4:cmd Change the issue:

The. cmd file can only be automatically generated by the configuration of the RTSC platform and cannot be manually changed by itself, and by editing the modified. Cmd in the compilation again will be changed back.

5:sys/bios How to customize a segment:

Manually edit the. cfg file: program.sectmap["L3_data"]= "DDR";


TI Real-time operating system Sys/bios Usage Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.