#551 closed defect (fixed)

rtems_task_set_priority() bug when holding mutexes w/o priority discipline

Reported by: Thomas Rauscher Owned by: Joel Sherrill
Priority: normal Milestone: 2
Component: score Version: 4.5
Severity: major Keywords:
Cc: bugs@… Blocked By:
Blocking:

Description

A task owning a non-priority discipline mutex
cannot lower its priority or get its priority lowered by another task.
rtems_task_set_priority() returns RTEMS_SUCCESS, but
the priority is not lowered at all, even after releasing
the mutex.

The problem is that for a task owning only fifo and/or priority mutexes, the task priority is not changed
immediately or at least when the 'resource_count' in
the thread control structure is decremented back to zero.

Release:
RTEMS-4.5

How-To-Repeat:
#include <rtems.h>
#include <stdio.h>
#include <stdlib.h>

static int passed = 1;

static void set_pri(rtems_task_priority newpri)
{

rtems_task_priority oldpri, verify;


rtems_task_set_priority(RTEMS_SELF, newpri, &oldpri);
rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &verify);

if(verify != newpri) {

printf("!! Cannot set priority from %i to %i (is %i now)\n",

oldpri, newpri, verify);

passed = 0;

}

}

rtems_task my_main(rtems_task_argument ignored)
{

rtems_id sem;
rtems_task_priority pri;
(void) ignored;

set_pri(64);

printf("Trying to lower priority without owning a mutex\n");
set_pri(128);


printf("Trying to raise priority without owning a mutex\n");
set_pri(64);

printf("Obtaining a mutex\n");
if(rtems_semaphore_create(rtems_build_name('S','E','M','1'), 0,

RTEMS_FIFO|RTEMS_BINARY_SEMAPHORE, 0,
&sem) != RTEMS_SUCCESSFUL) {

printf("Cannot create mutex\n");
exit(1);

}

printf("Trying to lower priority owning a mutex\n");
set_pri(128);

printf("Releasing the mutex\n");
if(rtems_semaphore_release(sem) != RTEMS_SUCCESSFUL) {

printf("Cannot release mutex\n");
exit(1);

}

rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &pri);
if(pri!=128) {

printf("!! Priority is %i (not %i) after releasing the semaphore\n",

pri, 128);

passed = 0;

}

printf("Test %s\n", passed ? "PASSED" : "FAILED");


rtems_task_delete(RTEMS_SELF);

}

Change History (1)

comment:1 Changed on Feb 26, 2004 at 3:51:40 PM by Joel Sherrill

Status: assignedclosed

State-Changed-From-To: open->closed
State-Changed-Why: Fixed in 4.6 and trunk.

Note: See TracTickets for help on using tickets.