OSEK OS Resource management

本文深入探讨了资源管理的概念,包括并发访问控制、优先级调度、内存与硬件区域管理等,并介绍了如何避免优先级反转和死锁。此外,文章还详细解释了内部资源的使用场景,特别强调了在特定情况下防止不必要的重新调度。优先级天花板协议和内部资源的管理机制是文章的核心内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

qThe resource management is used to co-ordinate concurrent accesses of several tasks with different priorities to shared resources

ve.g.management entities (scheduler), program sequences, memory or hardware areas.

vThe resource management can optionally be extended to co-ordinate concurrent accesses of tasks and interrupt service routines.

qResource management ensures that

vtwo tasks cannot occupy the same resource at the same time.

vpriority inversion cannot occur.

vdeadlocks do not occur by use of these resources.

vaccess to resources never results in a waiting state.

qIf the user requires protection against interruptions not only caused by tasks, but also caused by interrupts, he/she can also use the operating system services to enable/disable interrupts which do not cause rescheduling.

qRestrictions when using resources

vTerminateTask,ChainTask,Schedule,WaitEvent shall not be called while a resource is occupied.

vInterrupt service routine shall not be completed with a resource occupied.

qScheduler as a resource

vIf a task shall protect itself against preemptions by other tasks, it can lock the scheduler.

vThe scheduler is treated like a resource which is accessible to all tasks.

 优先级反转(低优先级的任务T4占有信号量S1,导致最高优先级的任务T1不能使用S1而进入等待状态,而此时比T1优先级低的任务T2,T3得以运行)

6d81800a19d8bc3e5298fb34808ba61ea9d345b8.jpg

 死锁(任务T1占用信号量S1,等待S2;任务T2占用信号量S2,等待S1

0dd7912397dda1440f50914cb0b7d0a20df486f7.jpg

qOSEK Priority Ceiling Protocol(优先级天花板协议优先级最高协议)

vTo avoid the problems of priority inversion and deadlocks:

§At the system generation, to each resource its own ceiling priority is statically assigned.

 üThe ceiling priority shall be set at least to the highest priority of all tasks that access a resource or any of the resources linked to this resource.

üThe ceiling priority shall be lower than the lowest priority of all tasks that do not access the resource, and which have priorities higher than the highest priority of all tasks that access the resource.

§If a task requires a resource, and its current priority is lower than the ceiling priority of the resource, the priority of the task is raised to the ceiling priority of the resource.

§If the task releases the resource, the priority of this task is reset to the priority which was dynamically assigned before requiring that resource.

 

1b4c510fd9f9d72ae40eece3d62a2834359bbbe2.jpg

 

qInternal Resources

vInternal resources are resources which are not visible to the user and therefore can not be addressed by the system functions GetResource and ReleaseResource.

§managed strictly internally within a clearly defined set of system functions.

§the behaviour of internal resources is exactly the same as standard resources (priority ceiling protocol etc.).

vInternal resources are restricted to tasks.

 §Atmost one internal resource can be assigned to a task during system generation. vIf an internal resource is assigned to a task, the internal resource is managed asfollows:

§The resource is automatically taken when the task entersthe running state,except when it has already taken the resource.

üAs a result, the priority of the task is automatically changed to the ceiling priority of the resource.

§At the points of rescheduling, the resource is automatically released.

 vInternal resources can be used in all cases when it is necessary to avoid not-wanted rescheduling within a group of tasks.


转载于:https://www.cnblogs.com/iable/p/4206845.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值