zircon内核替代linux内核,zircon 内核使用C++的原则

新版内核改动非常大,感觉有人写的书要大改了[偷笑]。看上数百行代码似乎就能了解其结构了。

在内核里使用了C++,这么做不无代价,严格的原则很有意思。

C++ in Zircon

A subset of the C++14 language is used in the Zircon tree. This includes both the upper layers of the kernel (above the lk layer), as well as some userspace code. In particular, Zircon does not use the C++ standard library, and many language features are not used or allowed.

Language features

- Not allowed

Exceptions

RTTI and dynamic_cast

Operator overloading

Default parameters

Virtual inheritance

Statically constructed objects

Trailing return type syntax

Exception: when necessary for lambdas with otherwise unutterable return types

Initializer lists

thread_local in kernel code

- Allowed

Pure interface inheritance

Lambdas

constexpr

nullptr

enum classes

templates

Plain old classes

auto

Multiple implementation inheritance

But be judicious. This is used widely for e.g. intrusive container mixins.

- Needs more ruling TODO(cpu)

Global constructors

Currently we have these for global data structures.

Linux Kernel 尝试过C++,最后失败告终。有这些原则我看到了C++在内核发扬光大的曙光。

Exception, dynamic_cast 多少年了我都不愿意用,经历的血泪太多了。没有太多复杂对象,Operator overloading 也没有什么用武之地。借C++编译器的强大让代码组织方便一点没有坏处。

设备的支持,去掉了pixel,只剩下: acer12, hikey960, nuc, rpi3。下个月入手一台intel nuc看看内核,也能作为日常使用。

妄自瞎说开始:

感觉内核技术发展这么多年后,zircon的实践会很有意思。实用主义会让这个内核大放异彩,会又各种嵌入式系统改用它。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值