#2148 closed defect (fixed)

Blackfin doesn't switch tasks, resets dispatch_necessary before querying it

Reported by: Kolja Waschk Owned by: Joel Sherrill
Priority: highest Milestone: 4.11
Component: score Version: 4.11
Severity: normal Keywords:
Cc: sebastian.huber@… Blocked By:

Description (last modified by Joel Sherrill)

Problem xperienced with bf537Stamp BSP on real hardware (a board with ADSP-BF537 and just SDRAM and flash attached, only PLL, SDRAM, and UART are initialized):

The ticker sample starts its three tasks, but all stall forever in rtems_task_wake_after(x) for any x greater than 1. Only the Idle task runs.

The clockISR and rtems_clock_tick are executed and clock count is incremented.

Debugging via JTAG with breakpoint at _Thread_Delay_ends made me discover that:

  1. _Thread_Dispatch_necessary = true is set by _Scheduler_priority_unblock
  1. Then it is cleared in cpukit/score/cpu/bfin/cpu_asm.S:480 (doDispatch) by writing 0 to DISPATCH_NEEDED
  1. Finally _Thread_Dispatch, called by _ISR15_Handler, doesn't do any Context_Switch because per_cpu->dispatch_necessary (the very same byte) is zero.

As a workaround, removing the two lines after doDispatch in cpu_asm.S leads to a running ticker sample.


/* r0 = 0: */
/* B[p0] = r0; */
raise 15;

I have not tried other tests yet. I suspect some more inconsistencies. This doesn't appear like it ever worked...?

Also see discussion here:

Another occurence with similar outcome, maybe for the same reason:

Probably in RTEMS since 2008, with background e.g. discussed here:

Change History (7)

comment:1 Changed on 10/16/13 at 06:30:08 by Sebastian Huber

Cc: Sebastian Huber added

comment:2 Changed on 08/20/14 at 04:47:08 by Sebastian Huber

The general interrupt with thread dispatch sequence is depicted here:


comment:3 Changed on 11/22/14 at 16:17:16 by Joel Sherrill

Description: modified (diff)

I have no recollection of a patch being submitted. Does anyone else?

Also the URLs for mail point to the old mhonarc archives so I am having trouble finding what they are talking about.

comment:4 Changed on 11/24/14 at 10:34:10 by Kolja Waschk

There is no patch yet. We produce devices that are running very stable now, with the modification as noted in the issue description (commenting out the two lines in cpu_asm.S). But I have not been able to correctly identify all possible side effects nor run all tests (due to other problems).

Updates for the links:

Also see discussion here ("ticker hangs on bf537Stamp"):

Another occurence with similar outcome, maybe for the same reason ("bfin simulator problems"):

Probably in RTEMS since 2008, with background e.g. discussed here ("Problems with the blackfin port"):

comment:5 Changed on 11/24/14 at 18:58:28 by Gedare Bloom

Version: HEAD4.11

Replace Version=HEAD with Version=4.11 for the tickets with Milestone >= 4.11

comment:6 Changed on 12/19/14 at 05:06:18 by Gedare Bloom

Priority: normalhighest

Bump priority to highest for tickets with a fix attached or seemingly simple fix proposed in the description or comments.

comment:7 Changed on 02/19/15 at 20:50:38 by Gedare Bloom <gedare@…>

Resolution: fixed
Status: newclosed

In 7f1bb40aa1b87bc346bd07b893ebdd5c35e10410/rtems:

bfin: do not reset dispatch needed

Closes #2148

Fix suggested in above ticket. On examination, the assembly
appears to be clearing the DISPATCH_NEEDED flag before jumping
to _Thread_Dispatch.

Note: See TracTickets for help on using tickets.