#1241 closed defect (fixed)

Semaphore lost during requeueing due to priority inheritance

Reported by: Johan Zandin Owned by: Joel Sherrill
Priority: normal Milestone: 4.8
Component: score Version: 4.8
Severity: major Keywords:
Cc: johan.zandin@… Blocked By:
Blocking:

Description

In the following scenario, the S semaphore is never recieved by Task 2. This causes both tasks (and any other tasks requesting the R semaphore) to wait indefinitely:

  1. Task 1 has higher priority than Task 2, S is a synchronization semaphore (simple binary semaphore with tasks wait by fifo) and R is a resource semaphore (binary semaphore with tasks wait by priority and priority inheritance).
  2. Task 2 has locked R and is waiting for S.
  3. Task 1 tries to lock R, which increases the priority of Task 2.
  4. When_Thread_Change_priority execute in the unprotected region around the call to _Thread_queue_Requeue, it is interrupted by an ISR signalling S.

Cause:
The read-modify-write of current_state (on the lines surrounding the unprotected region) can't handle that current_state is updated within the unprotected region, (due to the signaling of S).
Also, there seems to be a similar problem within _Thread_queue_Requeue, where interrupts are enabled while the task is temporarily outside of the queue. If S is signaled at that occasion, it may give similar symptoms. But note that this branch of the code will only be reached if tasks wait on S by priority.

Attachments (2)

pr1241.diff (7.9 KB) - added by Joel Sherrill on May 2, 2007 at 3:37:35 PM.
Patch for CVS head
pr1241a.diff (2.1 KB) - added by Joel Sherrill on May 10, 2007 at 4:41:17 PM.
Revised patch which includes only necessary changes

Download all attachments as: .zip

Change History (6)

comment:1 Changed on Apr 27, 2007 at 3:24:52 PM by Johan Zandin

Cc: Johan Zandin added

comment:2 Changed on May 2, 2007 at 1:23:21 PM by Johan Zandin

Component: misccpukit
Version: 4.54.8

Changed on May 2, 2007 at 3:37:35 PM by Joel Sherrill

Attachment: pr1241.diff added

Patch for CVS head

Changed on May 10, 2007 at 4:41:17 PM by Joel Sherrill

Attachment: pr1241a.diff added

Revised patch which includes only necessary changes

comment:3 Changed on May 10, 2007 at 4:41:17 PM by Joel Sherrill

attachments.isobsolete: 01

comment:4 Changed on May 10, 2007 at 5:48:01 PM by Joel Sherrill

Resolution: fixed
Status: newclosed

Patch committed to CVS head.

Note: See TracTickets for help on using tickets.