ChibiOS简介5/5

1. 源由

作为后续研读Ardupilot的ChibiOS的垫脚石,先了解下ChibiOS系统。


Ardupilot ChibiOS项目: https://github.com/ArduPilot/ChibiOS

Artery(AT32) porting项目: //Artery官网没有相关porting动作,不过开源github有相关项目。

2. ChibiOS基础知识5/5

2.16 Chapter 16 - The OS Library

The OS Library (OSLIB) is an optional set of RTOS features that can be added on top of both RT and NIL kernels. It is purely a source code architectural decision.

Requirements

  • Features that only use the common RT and NIL common API.
  • Features that cannot be optimized using tricks or details of the underlying RT or NIL kernels.
  • Features that are CPU architecture agnostic.
  • Features that are compiler agnostic.
  • Features that have no dependencies on external modules other than RT or NIL kernels.

2.16.1 Memory Allocators

The 4 kinds of allocators are designed to work together:

  • Core Allocator, for one-way memory allocation, memory cannot be freed.
  • Pool Allocator, for allocating and freeing fixed-size objects.
  • Guarded Pool Allocator, it is like the pool allocator but guarded by a semaphore. Trying to allocate an object causes the caller thread to wait if an object is not immediately available.
  • Heap Allocator, for allocating and freeing arbitrary-size memory blocks.

The above mechanisms were previously in the RT kernel and have been moved into OSLIB.

Allocators Comparison

Here is a table summarizing the information:

AllocatorCan FreeConstant TimeVariable SizeFrom ISRCreates FragmentsThread Safe
Core AllocatorNoYesYesYes-Yes
Pool AllocatorYesYesNoYesNoYes
Guarded Pool AllocatorYesNoNoYes1NoYes
Heap AllocatorYesNoYesNoYesYes
C Library AllocatorYesNoYesNoYesNo2
  1. Without waiting.
  2. Depends on library implementation and integration with the RTOS.
  • Can Free indicates the ability of the allocator to return blocks to the available memory.
  • Constant Time is the ability to allocate/free blocks in a constant time, this is important for system determinism.
  • Variable Size is the ability to allocate/free blocks of variable size.
  • From ISR indicates that the allocator services can also be called from ISR context.
  • Creates Fragments indicates if allocating and freeing memory can cause internal fragmentation.
  • Thread Safe indicates that the allocator can be used in a multi-threaded environment.

2.16.2 Binary Semaphores

A variation on the semaphore mechanism with only two internal states, this mechanism was previously in the RT kernel and has been moved into OSLIB.

在这里插入图片描述

2.16.3 Mailboxes

Queues of asynchronous messages, this mechanism was previously in the RT kernel and has been moved into OSLIB.

在这里插入图片描述

2.16.4 Objects FIFOs

Queues of objects composed by a pool of free object and a mailbox for pointers exchange. It is useful when there is the need to exchange fixed-size objects in a copy-less way.

在这里插入图片描述

2.16.5 Pipes

Structure-less streams of bytes exchanged between threads.

2.16.6 Delegate Threads

It is a mechanism that allows to perform function calls in the context of another thread which is acting as a “functions server thread”. Function calls are “delegated” to a dedicated thread which performs the call synchronously.

2.16.7 Jobs Queues

Implements a queue of “jobs” that are consumed and executed by a “jobs server thread” asynchronously. A job is simply a structure containing a function pointer and a pointer argument.

2.16.8 Objects Caches

Implements a cache of fixed-size objects which can be then retrieved by their numeric identifier. It could be used for a disk cache for example.

2.16.9 Objects Factory

A system that allows to allocate other objects dynamically and attribute them a name. Objects can be used by reference, references can be obtained by searching for name.

2.16.10 Notes on Testing

The OSLIB has its own suite of tests, the tests are performed on both RT and NIL host kernels.

3. 参考资料

【1】ArduPilot开源飞控系统之简单介绍
【2】Ardupilot开源飞控之ChibiOS简介
【3】 ChibiOS官方文档

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值