Friday, February 23rd 2018, 7:51am UTC+1

You are not logged in.

  • Login
  • Register

Chu-Lih

Beginner

Date of registration: Mar 27th 2014

Posts: 2

1

Monday, August 4th 2014, 4:29am

Priority inheritance when OS_USE is called

Hi,
We understand form the user manual, the OS has the following behaviour when we call
OS_Use()
Quote" Case C: The resource is being used by another task.
The execution of this task is suspended until the resource semaphore is released.
In the meantime if the task blocked by the resource semaphore has a higher priority
than the task blocking the semaphore, the blocking task is assigned the priority
of the task requesting the resource semaphore. This is called priority
inheritance. Priority inheritance can only temporarily increase the priority of a
task, never reduce it."
When we executed OS_Use() in Task A and inherited the priority of the higher priority task (Task B) which also calls OS_Use(), Task A we call
OS_GetPriority()and we noticed that priority of A was not changed to higher priority but reflecting the base priority.
best regards
Chu-Lih


TaskA()
{
OS_Use(&pRSema);
OS_Delay(30);
OS_GetPriority(NULL);
while (1)
{}
}

TaskA()
{
OS_Delay(20);
OS_Use(&pRSema);
while (1)
{}
}

SEGGER - Til

Super Moderator

Date of registration: Nov 14th 2007

Posts: 264

2

Tuesday, August 5th 2014, 2:00pm

Hello Chu-Lih,

the priority inversion is handled with priority inheritance which means that the low priority task is activated until it releases the resource semaphore.
The scheduler will activate the low prio task TaskA() instead of the high prio task TaskB() when it detects that the resource is being used by another task.
But this is completely handled internally so you will not see any modified priority in the tasks.

Best regards,
Til

Chu-Lih

Beginner

Date of registration: Mar 27th 2014

Posts: 2

3

Thursday, August 7th 2014, 8:39am

Hi Til,

Understand and thank you for the support. :thumbsup:

Best Regards
Chu-Lih