目录

QNX介绍

QNX优缺点

qnx 4.0

kernel mode 和user mode 区别

kernel space 和user space 区别 

操作系统内核种类: monolithic kernel vs microkernel

kernel serivce包含哪些:

疑问:vxworks为什么是微内核?linux为什么是宏内核

qnx与vxworks区别

windows CE,linux和vxworks 区别

kernel相关名词列表


QNX介绍

QNX的微内核,消息传递,硬实时性,高可靠性,使它在嵌入式领域应用很广。

QNX为微内核的架构,微内核只提供进程调度、进程间通信、底层网络通信和中断处理四种服务。

驱动程序、协议栈、文件系统、应用程序等都在微内核之外内存受保护的安全的用户空间内运行,组件之间能避免相互影响,在遇到故障时也能重启。

因此QNX核心非常小巧 (QNX4.x大约为12Kb)而且运行速度极快。

QNX Neutrino通过两个基本的原则,达到了独一无二的有效性、模块化和简洁性:

  • 微内核架构
  • 基于消息的进程间通信

QNX优缺点

  1、遵循POSIX标准,主要使用方式与编程接口与Linux相近,易学习。

  2、QNX是一个微内核的系统,你可以任意裁减,定制适合自己的最小化方案。

  3、QNX不区分驱动、系统服务和用户运用,可以自由实现。

  4、使用群体很小,没有很好的社区支持。出了问题能够提供帮组的人不多。

基本特征、体系结构异同、调度策略分析、操作系统服务比较、系统开放性对比。

实例:

void *mosquitto__thread_main(void *obj)

{

printf("thread st\n");

while(1)

{

pthread_mutex_lock(¤t_out_packet_mutex);

//同一个任务连续上锁,在linux中这里会死锁,但是QNX会返回上锁失败,不会死锁

pthread_mutex_lock(¤t_out_packet_mutex);

printf("thread \n");

pthread_mutex_unlock(¤t_out_packet_mutex);

sleep(1);

}

}

qnx 4.0

qnx是微内核系统

OS模块之间的所有通信都是通过标准的系统IPC服务进行的。因此,由一个资源管理器引入的错误将被限制在该子系统,而不会损坏系统中其他不相关的资源管理器。

下表给出了组成QNX系统的各个模块的源代码行数和代码大小(本文中的所有源代码行数都是通过计算C源文件中的分号生成的)。

代码行数

代码大小

Microkernel

605

7KB

Proc

3924

52KB

Fsys

4457

57KB

Fsys.ahascsi

596

11KB

Dev

2204

23KB

Dev.con

1885

19KB

Net

1142

18KB

Net.ether

1117

17KB

15930行

204KB

refer to https://blog.csdn.net/nibiewuxuanze/article/details/103535875

kernel mode 和user mode 区别

What is basic difference between Kernel mode and User mode?

Kernel Mode: In Kernel mode, the executing code has complete and unrestricted access to the underlying hardware. It can execute any CPU instruction and reference any valid memory address. Any operating system function below the system call layer, executes in kernel mode. Crashes in kernel mode are catastrophic; they will halt the entire PC because there is no other software layer to handle the crashes.

User Mode: In User mode, the executing code has no ability to directly access hardware or reference kernel memory. Code running in user mode must delegate to system APIs to access hardware or kernel memory. Most of the code running on your computer will execute in user mode.

If the CPU doesn’t have an MMU then it doesn’t exist - as kernel mode and user mode are the same.

User mode/Kernel mode is a state of an MMU tied to a processor.

It is used to flag the use of privileged functions (like changing the MMU configuration, perform I/O, handle hardware traps/errors.

Generally the CPU will also provide alternate registers for kernel mode operation.

kernel space 和user space 区别 

The really simplified answer is that the kernel runs in kernel space, and normal programs run in user space.

User space is basically a form of sand-boxing -- it restricts user programs so they can't mess with memory (and other resources) owned by other programs or by the OS kernel. 

Userspace is just applications running in user mode restricted in access by the MMU, and only able to access the user mode registers.

refer to https://techdifferences.com/difference-between-microkernel-and-monolithic-kernel.html

操作系统内核种类: monolithic kernel vs microkernel

操作系统内核可以分为两大阵营:单内核(亦称:宏内核)和微内核(第三阵营是外内核,主要用在科研系统中)。

内核逻辑+部分用户逻辑运行在kernel mode下,是monolithic kernel

只有kernel服务运行在 kernel mode下,其他逻辑运行在user mode下,则是microkernel

注意:

kernel mode : 逻辑运行在kernel space上。

user mode: 逻辑运行在user space 上。

二者特点:

monolithic kernel: 运行效率高,扩展繁琐。大内核

microkernel: 运行效率稍等,扩展方便。小内核

kernel serivce包含哪些:

任务调度,lower-level中断管理,IPC, low-level网络通讯。

可选:文件管理,内存管理,etc。

Microkernel

  • It is smaller in size.

  • In this kernel, the services are kept in a separate address space.

  • It executes slowly in comparison to monolithic kernel.

  • It can be extended easily.

  • If a service crashes, it effects the working of the microkernel.

  • The code to build a microkernel is large.

  • Examples of microkernel include: QNX, Symbian, L4Linux, Singularity, K42, Integrity, PikeOS, HURD, Minix, Mac OS X, and Coyotos.

Monolithic Kernel

  • In monolithic kernel, both user services and kernel services are kept in the same address space.

  • Monolithic kernel is larger than microkernel.

  • It executes quickly in comparison to microkernel.

  • It is difficult to extend a monolithic kernel.

  • If a service crashes, the entire system crashes when a monolithic kernel is used.

  • Less code is required to build a monolithic kernel.

  • Examples of monolithic kernel include: Linux, BSDs (FreeBSD, OpenBSD, NetBSD), OS-9, AIX, HP-UX, DOS, OpenVMS, XTS-400, Microsoft Windows (95,98,Me), and Solaris.

BASIS FOR COMPARISONMICROKERNELMONOLITHIC KERNEL
BasicIn microkernel user services and kernel services are kept in separate address space.In monolithic kernel, both user services and kernel services are kept in the same address space.
SizeMicrokernel are smaller in size.Monolithic kernel is larger than microkernel.
ExecutionSlow execution.Fast execution.
ExtendibleThe microkernel is easily extendible.The monolithic kernel is hard to extend.
SecurityIf a service crashes, it does effect on working of microkernel.If a service crashes, the whole system crashes in monolithic kernel.
CodeTo write a microkernel, more code is required.To write a monolithic kernel, less code is required.
ExampleQNX, Symbian, L4Linux, Singularity, K42, Mac OS X, Integrity, PikeOS, HURD, Minix, and Coyotos.Linux, BSDs (FreeBSD, OpenBSD, NetBSD), Microsoft Windows (95,98,Me), Solaris, OS-9, AIX, HP-UX, DOS, OpenVMS, XTS-400 etc.

Monolithic-kernel单内核

疑问:vxworks为什么是微内核?linux为什么是宏内核

解释:

vxworks内核中,只提供系统服务,没有用户服务。 只是user space和kernel space一致。看起来像monolithic  kernel。

linux内核是monolithic,虽然也区分了user space和kernel space。单kernel space中运行了大量的user service。

qnx与vxworks区别

vxworks是micro kernel。单7.0之前的版本,所有逻辑都运行在内核空间(不是 kernel mode),因而很像monolithic kernel.

If any service fails the entire system crashes, and it is one of the drawbacks of this kernel. The entire operating system needs modification if user adds a new service.

二者区别是:

vxworks 7之前的版本,使用统一地址空间方式。

vxworks7及之后,区分kernel space和user space。

qnx始终,区分内核空间和用户空间。

此处vxworks是monolithic kernel,有误。

windows CE,linux和vxworks 区别

refer to https://www.ripublication.com/ijaer17/ijaerv12n18_113.pdf

kernel相关名词列表

Operating systems

General
Variants
Kernel
Architectures
Components
Process management
Concepts
Scheduling
algorithms
Memory management,
resource protection
Storage access,
file systems
Supporting concepts

refer to https://en.wikipedia.org/wiki/Monolithic_kernel

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐