zephyr的执行上下文(多线程)

Zephyr内核支持任务线程、纤程和中断上下文三种执行模式。任务线程基于优先级抢占,可能启用时间片轮转;纤程轻量且不可抢占,执行优先于任务线程;中断上下文优先级最高,处理中断处理程序。微内核不限制任务和纤程数量,而纳米内核仅支持单个任务。
摘要由CSDN通过智能技术生成

zepyhr的内核支持三种类型的多线程:

1、任务线程,可抢占,通常用来执行冗长和复杂的事务。任务的调度基于优先级,任务执行时高优先级任务抢占低优先级任务。

内核可选支持时间片轮转调度,也就是说同优先级别的任务可以轮流执行,不会出现CPU被独占的风险(换句话说,看样

子是打开时间片轮转且所有线程优先级相等此时才会出现cpu不被独占)。

2、纤程,轻量级的不可抢占线程,通常用于设备驱动程序和性能的关键性工作,也是基于优先级调度,纤程在操作阻塞时被

调度,纤程的执行权限优先于任务线程,也就是说任务线程的执行需要在所有纤程被执行完后才能得到调度执行。

3、中断上下文,内核中执行权限最高,用于处理ISRs(中断处理程序)。只有在所有ISR被处理完成后纤程、任务线程才会

得到CPU的执行。

调度的情况大致上 ISR-->纤程-->任务线程,看样子没有并发的情况。

zephyr不同内核在app使用任务线程和纤程上的区别:

microkernel 不限制app使用任务线程或者纤尘的个数

nanokernel 限制app只能使用单个。


The Zephyr kernel supports multi-threaded processing for three types of execution contexts.

  • task context is a preemptible thread, normally used to perform processing that is lengthy or complex. Task scheduling is priority-based, so that the execution of a higher priority task preempts the execution of a lower priority task. The kernel also supports an optional round-robin time slicing capability so that equal priority tasks can execute in turn, without the risk of any one task monopolizing the CPU.
  • fiber context is a lightweight and non-preemptible thread, typically used for device drivers and performance critical work. Fiber scheduling is priority-based, so that a higher priority fiber is scheduled for execution before a lower priority fiber; however, once a fiber is scheduled it remains scheduled until it performs an operation that blocks its own execution. Fiber execution takes precedence over task execution, so tasks execute only when no fiber can be scheduled.
  • The interrupt context is a special kernel context used to execute ISRs Interrupt Service Routines. The interrupt context takes precedence over all other contexts, so tasks and fibers execute only when no ISR needs to run. (See below for more on interrupt handling.)

The Zephyr microkernel does not limit the number of tasks or fibers used in an application; however, an application that uses only the nanokernel is limited to a single task.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值