RT-Thread kernel-kernel API update log ①

RT-Thread kernel-kernel API update log①

  • RT-Thread Kernel-Kernel API Update Log
    • RT-Thread kernel-kernel API update log summary
      • 1. New functions
      • 2. Improvement and optimization
      • 3. Fix the problem
      • 4. Summary
    • Kernel API update log
      • 5.0.1
        • API addition:
      • 5.0.0
        • API addition:
      • 4.1.1
        • 4.1.1-beta
      • 4.1.0
        • API addition:
        • API removal:
        • API changes:
      • 4.0.4
        • API addition:
        • API removal:
        • API changes:
      • 4.0.3
        • API addition:
        • API removal:
        • API changes:
      • 4.0.2
        • API addition:
        • API changes:
      • 4.0.1
        • API changes:
      • 4.0.0
        • API changes:
      • 3.1.1

RT-Thread kernel-kernel API update log

RT-Thread kernel-kernel API update log summary

RT-Thread is an open source embedded real-time operating system that provides a rich set of kernel APIs for developers to use in applications. This article will briefly introduce the change log of RT-Thread core API to help developers better understand its functions and changes.

1. New functions

  1. Inter-thread synchronization mechanism enhancement: RT-Thread kernel adds new synchronization mechanism, including condition variables, semaphores and mutex locks. These mechanisms can help developers better coordinate operations between threads in a multi-threaded environment and improve program reliability and stability.
  2. Richer device driver support: The RT-Thread kernel adds support for more devices, including serial ports, CAN bus, I2C bus, SPI bus, etc. These device drivers provide developers with more hardware operation interfaces, making programs more flexible and scalable.
  3. More efficient memory management: The RT-Thread kernel improves the memory management mechanism, adds large page support, and improves the efficiency of memory allocation and release. In addition, support for dynamic memory allocation has been added, allowing developers to flexibly allocate memory according to actual needs.
  4. More powerful network support: The RT-Thread kernel adds support for more network protocols, including TCP/IP, UDP, HTTP, etc. In addition, support for network packetization/unpackaging has been added, making it easier for developers to perform network programming.
  5. Better file system support: The RT-Thread kernel adds support for more file systems, including FAT, NTFS, EXT, etc. These file system supports make it easier for developers to access data in the file system.

2. Improvement and optimization

  1. Optimized task scheduling: The RT-Thread kernel improves the task scheduling algorithm, allowing the system to schedule tasks more intelligently based on task priority and system load, improving the system’s response speed and task execution efficiency.
  2. Optimized interrupt processing: The RT-Thread kernel improves the interrupt processing mechanism and improves the efficiency of interrupt processing. In addition, support for interrupt nesting has been added, allowing the system to handle multiple interrupts more efficiently.
  3. Optimized memory allocation: The RT-Thread kernel improves the memory allocation mechanism so that the system can allocate and release memory more efficiently. In addition, support for memory leak detection has been added to help developers find and solve memory leak problems in time.
  4. Optimized device driver: RT-Thread kernel optimizes the device driver architecture, making device driver writing and maintenance easier and more convenient. In addition, hot-plug support for device drivers has been added, allowing developers to add or remove device drivers more conveniently.
  5. Optimized network packetizing/unpacking: The RT-Thread kernel optimizes the network packetizing/unpacking mechanism, allowing developers to more conveniently transmit and process network data. In addition, support for multiple network protocols has been added to improve the flexibility of network programming.

3. Fix problems

The RT-Thread kernel has also fixed many issues during the continuous update process. For example, the problem of abnormal task scheduling in some cases has been fixed; the problem of improper interrupt handling in some cases has been fixed; the problem of uneven memory allocation in some cases has been fixed; the problem of unstable device drivers in some cases has been fixed. Problem; Fixed network packet/unpacket abnormality in some cases, etc. After these issues have been fixed, the stability and reliability of the RT-Thread kernel have been further improved.

4. Summary

The change log of the RT-Thread kernel records its improvements and optimizations in functionality, performance and stability. The new synchronization mechanism, device driver, memory management, network support and file system support provide developers with a more comprehensive and flexible development environment. At the same time, the stability and reliability of the RT-Thread kernel have been further improved by optimizing mechanisms such as task scheduling, interrupt handling, memory allocation, device drivers, and network packetization/unpacking. In future development, the RT-Thread core will continue to improve its functions and performance to provide developers with better services.

Kernel API update log

When the rt-thread source code is released, if the kernel (src) API is updated, the detailed changes to the kernel API will be recorded here.

Note: SMP-related interfaces are not included yet. The log content includes: API addition, API deletion, and API change.

5.0.1

API added:
/* ----- irq.c ----- */
rt_weak rt_bool_t rt_hw_interrupt_is_disabled(void) /* 5.0.1 */

/* ----- object.c ----- */
rt_err_t rt_object_get_name(rt_object_t object, char *name, rt_uint8_t name_size) /* 5.0.1 */

/* ----- thread.c ----- */
rt_err_t rt_thread_get_name(rt_thread_t thread, char *name, rt_uint8_t name_size) /* 5.0.1 */

API changes:

/* ----- ipc.c ----- */
/* The API return value type related to message queue reception is updated, from rt_err_t (reception success/failure) to rt_ssize_t (actual message size received) */
rt_ssize_t rt_mq_recv(rt_mq_t mq,
                    void *buffer,
                    rt_size_t size,
                    rt_int32_t timeout) /* 5.0.1 */
rt_err_t rt_mq_recv(rt_mq_t mq,
                    void *buffer,
                    rt_size_t size,
                    rt_int32_t timeout) /* 5.0.0 */

rt_ssize_t rt_mq_recv_interruptible(rt_mq_t mq,
                    void *buffer,
                    rt_size_t size,
                    rt_int32_t timeout) /* 5.0.1 */
rt_err_t rt_mq_recv_interruptible(rt_mq_t mq,
                    void *buffer,
                    rt_size_t size,
                    rt_int32_t timeout) /* 5.0.0 */

rt_ssize_t rt_mq_recv_killable(rt_mq_t mq,
                    void *buffer,
                    rt_size_t size,
                    rt_int32_t timeout) /* 5.0.1 */
rt_err_t rt_mq_recv_killable(rt_mq_t mq,
                    void *buffer,
                    rt_size_t size,
                    rt_int32_t timeout) /* 5.0.0 */

5.0.0

  • RT_WEAK changed to rt_weak
  • ALIGN changed to rt_align
  • Add driver.c file
  • scheduler.c is divided into scheduler_mp.c (SMP related) and scheduler_up.c (single core)
API added:
/* ----- device.c ----- */
// #ifdef RT_USING_DM
rt_err_t rt_device_bind_driver(rt_device_t device, rt_driver_t driver, void *node); /* 5.0.0 */
rt_device_t rt_device_create_since_driver(rt_driver_t drv,int device_id); /* 5.0.0 */
rt_err_t rt_device_probe_and_init(rt_device_t device); /* 5.0.0 */
// #endif


/* ----- driver.c (new) ----- */
// #ifdef RT_USING_DM
rt_err_t rt_driver_match_with_id(const rt_driver_t drv,int device_id); /* 5.0.0 */
rt_err_t rt_driver_match_with_dtb(const rt_driver_t drv,void *from_node,int max_dev_num); /* 5.0.0 */
// #endif


/* ----- ipc.c ----- */
rt_err_t rt_sem_take_interruptible(rt_sem_t sem, rt_int32_t timeout); /* 5.0.0 */
rt_err_t rt_sem_take_killable(rt_sem_t sem, rt_int32_t timeout); /* 5.0.0 */
void rt_mutex_drop_thread(rt_mutex_t mutex, rt_thread_t thread); /* 5.0.0 */
rt_uint8_t rt_mutex_setprioceiling(rt_mutex_t mutex, rt_uint8_t priority); /* 5.0.0 */
rt_uint8_t rt_mutex_getprioceiling(rt_mutex_t mutex); /* 5.0.0 */
rt_err_t rt_mutex_take_interruptible(rt_mutex_t mutex, rt_int32_t time); /* 5.0.0 */
rt_err_t rt_mutex_take_killable(rt_mutex_t mutex, rt_int32_t time); /* 5.0.0 */
rt_err_t rt_event_recv_interruptible(rt_event_t event,
                       rt_uint32_t set,
                       rt_uint8_t opt,
                       rt_int32_t timeout,
                       rt_uint32_t *recved); /* 5.0.0 */
rt_err_t rt_event_recv_killable(rt_event_t event,
                       rt_uint32_t set,
                       rt_uint8_t opt,
                       rt_int32_t timeout,
                       rt_uint32_t *recved); /* 5.0.0 */
rt_err_t rt_mb_send_wait_interruptible(rt_mailbox_t mb,
                         rt_ubas_t value,
                         rt_int32_t timeout); /* 5.0.0 */
rt_err_t rt_mb_send_wait_killable(rt_mailbox_t mb,
                         rt_ubas_t value,
                         rt_int32_t timeout); /* 5.0.0 */
rt_err_t rt_mb_recv_interruptibale(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout); /* 5.0.0 */
rt_err_t rt_mb_recv_killable(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout); /* 5.0.0 */
rt_err_t rt_mq_send_interrupt(rt_mq_t mq, const void *buffer, rt_size_t size); /* 5.0.0 */
rt_err_t rt_mq_send_killable(rt_mq_t mq, const void *buffer, rt_size_t size); /* 5.0.0 */
rt_err_t rt_mq_send_wait_interruptible(rt_mq_t mq,
                                    const void *buffer,
                                    rt_size_t size,
                                    rt_int32_t timeout); /* 5.0.0 */
rt_err_t rt_mq_send_wait_killable(rt_mq_t mq,
                                const void *buffer,
                                rt_size_t size,
                                rt_int32_t timeout); /* 5.0.0 */
rt_err_t rt_mq_recv_interruptible(rt_mq_t mq,
                                void *buffer,
                                rt_size_t size,
                                rt_int32_t timeout); /* 5.0.0 */
rt_err_t rt_mq_recv_killable(rt_mq_t mq,
                            void *buffer,
                            rt_size_t size,
                            rt_int32_t timeout); /* 5.0.0 */


/* ----- object.c ----- */
rt_object_t rt_custom_object_create(const char *name, void *data, rt_err_t (*data_destroy)(void *)) /* 5.0.0 */
rt_err_t rt_custom_object_destroy(rt_object_t obj) /* 5.0.0 */

API changes:

/* ----- device.c ----- */
rt_ssize_t rt_device_read(rt_device_t dev,
                         rt_off_t pos,
                         void *buffer,
                         rt_size_t size) /* 5.0.0 */
rt_size_t rt_device_read(rt_device_t dev,
                         rt_off_t pos,
                         void *buffer,
                         rt_size_t size) /* 4.1.1 */

rt_ssize_t rt_device_write(rt_device_t dev,
                          rt_off_t pos,
                          const void *buffer,
                          rt_size_t size); /* 5.0.0 */
rt_size_t rt_device_write(rt_device_t dev,
                          rt_off_t pos,
                          const void *buffer,
                          rt_size_t size); /* 4.1.1 */


/* ----- irq.c ----- */
rt_weak void rt_interrupt_enter(void) /* 5.0.0 */
        void rt_interrupt_enter(void) /* 4.1.1 */

rt_weak void rt_interrupt_leave(void) /* 5.0.0 */
        void rt_interrupt_leave(void) /* 4.1.1 */

rt_weak rt_uint8_t rt_interrupt_get_nest(void) /* 5.0.0 */
        rt_uint8_t rt_interrupt_get_nest(void) /* 4.1.1 */

4.1.1

There are no changes to the kernel API compared to 4.1.1-beta.

4.1.1-beta

API addition:

/* ----- kservice.c ----- */
RT_WEAK void rt_hw_us_delay(rt_uint32_t us) /* 4.1.1-beta */
const char *rt_strerror(rt_err_t error) /* 4.1.1-beta */

4.1.0

Organize memory-related files and APIs, and put the memory APIs used by users into kservice.c. Specifically:

When users use memory-related APIs, they generally choose one of three management algorithms: mem.c (small mem), memheap.c and slab.c. The APIs provided to users by these three files are the same. 4.1.0 Put the APIs provided to users in these three files into kservice.c.

Provide memory management algorithm API (such as rt_system_heap_init, rt_malloc, rt_free, etc.) in kservice.c, and add RT_WEAK modification to allow users to choose external memory management algorithms.

API added:
/* ----- clock.c ----- */
void rt_tick_sethook(void (*hook)(void)) /* 4.1.0 */


/* ----- kservice.c ----- */
char *rt_strcpy(char *dst, const char *src) /* 4.1.0 */
void rt_malloc_sethook(void (*hook)(void *ptr, rt_size_t size)) /* 4.1.0 */
void rt_free_sethook(void (*hook)(void *ptr)) /* 4.1.0 */
void *rt_page_alloc(rt_size_t npages) /* 4.1.0 */
void rt_page_free(void *addr, rt_size_t npages) /* 4.1.0 */


/* ----- memheap.c ----- */
void rt_memheap_info(struct rt_memheap *heap,
                     rt_size_t *total,
                     rt_size_t *used,
                     rt_size_t *max_used) /* 4.1.0 */
API removal:
/* ----- thread.c ----- */
void rt_thread_timeout(void *parameter) /* 4.1.0 delete*/
API changes:
/* ----- kservice.c ----- */
RT_WEAK void *rt_memcpy(void *dst, const void *src, rt_ubase_t count) /* 4.1.0 */
        void *rt_memcpy(void *dst, const void *src, rt_ubase_t count) /* 4.0.4 */

void *rt_memmove(void *dest, const void *src, rt_size_t n) /* 4.1.0 */
void *rt_memmove(void *dest, const void *src, rt_ubase_t n) /* 4.0.4 */

        rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_size_t count) /* 4.1.0 */
RT_WEAK rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count) /* 4.0.4 */

char *rt_strncpy(char *dst, const char *src, rt_size_t n) /* 4.1.0 */
char *rt_strncpy(char *dst, const char *src, rt_ubase_t n) /* 4.0.4 */

rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_size_t count) /* 4.1.0 */
rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_ubase_t count) /* 4.0.4 */

RT_WEAK int rt_vsnprintf(char *buf,
                        rt_size_t size,
                        const char *fmt,
                        va_list args) /* 4.1.0 */
rt_int32_t rt_vsnprintf(char *buf,
                        rt_size_t size,
                        const char *fmt,
                        va_list args) /* 4.0.4 */

       int rt_snprintf(char *buf, rt_size_t size, const char *fmt, ...) /* 4.1.0 */
rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *fmt, ...) /* 4.0.4 */

       int rt_vsprintf(char *buf, const char *format, va_list arg_ptr) /* 4.1.0 */
rt_int32_t rt_vsprintf(char *buf, const char *format, va_list arg_ptr) /* 4.0.4 */

       int rt_sprintf(char *buf, const char *format, ...) /* 4.1.0 */
rt_int32_t rt_sprintf(char *buf, const char *format, ...) /* 4.0.4 */

RT_WEAK int rt_kprintf(const char *fmt, ...) /* 4.1.0 */
RT_WEAK void rt_kprintf(const char *fmt, ...) /* 4.0.4 */


/* ----- Add RT_WEAK modification to the following memory-related APIs to allow users to use external memory management algorithms ----- */
RT_WEAK void rt_system_heap_init(void *begin_addr, void *end_addr) /* 4.1.0 */
RT_WEAK void *rt_malloc(rt_size_t size) /* 4.1.0 */
RT_WEAK void *rt_realloc(void *rmem, rt_size_t newsize) /* 4.1.0 */
RT_WEAK void *rt_calloc(rt_size_t count, rt_size_t size) /* 4.1.0 */
RT_WEAK void rt_free(void *rmem) /* 4.1.0 */
RT_WEAK void rt_memory_info(rt_size_t *total,
                             rt_size_t *used,
                             rt_size_t *max_used) /* 4.1.0 */

4.0.4

API added:
/* ----- idle.c ----- */
void rt_thread_defunct_enqueue(rt_thread_t thread) /* 4.0.4 */
rt_thread_t rt_thread_defunct_dequeue(void) /* 4.0.4 */


/* ----- ipc.c ----- */
rt_err_t rt_mutex_trytake(rt_mutex_t mutex) /* 4.0.4 */
rt_err_t rt_mb_urgent(rt_mailbox_t mb, rt_ubase_t value) /* 4.0.4 */


/* ----- scheduler.c ----- */
void rt_scheduler_switch_sethook(void (*hook)(struct rt_thread *tid)) /* 4.0.4 */
API removal:
/* ----- device.c ----- */
rt_err_t rt_device_init_all(void) /* 4.0.4 delete */
API changes:
/* ----- idle.c ----- */
/* Change the function name and use static modification */
static void rt_defunct_execute(void) /* 4.0.4 */
       void rt_thread_idle_excute(void) /* 4.0.3 */


/* ----- kservice.c, add RT_WEAK modification ----- */
RT_WEAK void *rt_memset(void *s, int c, rt_ubase_t count) /* 4.0.4 */
        void *rt_memset(void *s, int c, rt_ubase_t count) /* 4.0.3 */

RT_WEAK rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count) /* 4.0.4 */
        rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count) /* 4.0.3 */

RT_WEAK void rt_kprintf(const char *fmt, ...) /* 4.0.4 */
        void rt_kprintf(const char *fmt, ...) /* 4.0.3 */

RT_WEAK void *rt_malloc_align(rt_size_t size, rt_size_t align) /* 4.0.4 */
        void *rt_malloc_align(rt_size_t size, rt_size_t align) /* 4.0.3 */

RT_WEAK void rt_free_align(void *ptr) /* 4.0.4 */
        void rt_free_align(void *ptr) /* 4.0.3 */


/* ----- thread.c ----- */
static void _thread_exit(void) /* 4.0.4 */
       void rt_thread_exit(void) /* 4.0.3 */

4.0.3

API added:
/* ----- clock.c ----- */
RT_WEAK rt_tick_t rt_tick_get_millisecond(void) /* 4.0.3 */


/* ----- memheap.c ----- */
void rt_memory_info(rt_uint32_t *total,
                    rt_uint32_t *used,
                    rt_uint32_t *max_used) /* 4.0.3 */


/* ----- object.c ----- */
int rt_object_get_length(enum rt_object_class_type type) /* 4.0.3 */
int rt_object_get_pointers(enum rt_object_class_type type, rt_object_t *pointers, int maxlen) /* 4.0.3 */
API removal:
/* ----- clock.c ----- */
void rt_system_tick_init(void) /* 4.0.3 delete */


/* ----- object.c ----- */
void rt_system_object_init(void) /* 4.0.3 delete */
API changes:
/* ----- kservice.c ----- */
rt_int32_t rt_strcasecmp(const char *a, const char *b) /* 4.0.3 */
rt_uint32_t rt_strcasecmp(const char *a, const char *b) /* 4.0.2 */

4.0.2

API added:
/* ----- ipc.c ----- */
rt_err_t rt_mq_send_wait(rt_mq_t mq,
                         const void *buffer,
                         rt_size_t size,
                         rt_int32_t timeout) /* 4.0.2 */


/* ----- thread.c ----- */
rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick)
API changes:
/* ----- ipc.c ----- */
rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size) /* 4.0.2 */
rt_err_t rt_mq_urgent(rt_mq_t mq, void *buffer, rt_size_t size) /* 4.0.1 */


/* ----- irq.c ----- */
RT_WEAK rt_uint8_t rt_interrupt_get_nest(void) /* 4.0.2 */
        rt_uint8_t rt_interrupt_get_nest(void) /* 4.0.1 */

4.0.1

API changes:
/* ----- clock.c ----- */
rt_tick_t rt_tick_from_millisecond(rt_int32_t ms) /* 4.0.1 */
      int rt_tick_from_millisecond(rt_int32_t ms) /* 4.0.0 */

4.0.0

API changes:
/* ----- ipc.c ----- */
rt_err_t rt_mb_send(rt_mailbox_t mb, rt_ubase_t value) /* 4.0.0 */
rt_err_t rt_mb_send(rt_mailbox_t mb, rt_uint32_t value) /* 3.1.1 */

rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout) /* 4.0.0 */
rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_uint32_t *value, rt_int32_t timeout) /* 3.1.1 */


/* ----- memheap.c ----- */
rt_err_t rt_memheap_init(struct rt_memheap *memheap,
                         const char *name,
                         void *start_addr,
                         rt_size_t size) /* 4.0.0 */
rt_err_t rt_memheap_init(struct rt_memheap *memheap,
                         const char *name,
                         void *start_addr,
                         rt_uint32_t size) /* 3.1.1 */

void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size) /* 4.0.0 */
void *rt_memheap_alloc(struct rt_memheap *heap, rt_uint32_t size) /* 3.1.1 */

3.1.1

Click to view the API reference manual for version V3.1.1

I have questions: [email protected]