forked from Imagelibrary/rtems
SMP: Fix and optimize thread dispatching
According to the C11 and C++11 memory models only a read-modify-write operation guarantees that we read the last value written in modification order. Avoid the sequential consistent thread fence and instead use the inter-processor interrupt to set the thread dispatch necessary indicator.
This commit is contained in:
@@ -236,24 +236,18 @@ check_is_executing:
|
||||
beq try_update_is_executing
|
||||
mov 1, %g1
|
||||
|
||||
! Check if a thread dispatch is necessary
|
||||
ldub [%g6 + PER_CPU_DISPATCH_NEEDED], %g1
|
||||
cmp %g1, 0
|
||||
beq check_is_executing
|
||||
nop
|
||||
|
||||
! We have a new heir
|
||||
|
||||
! Clear the thread dispatch necessary flag
|
||||
stub %g0, [%g6 + PER_CPU_DISPATCH_NEEDED]
|
||||
|
||||
! Here we assume a strong memory order, otherwise a memory barrier must
|
||||
! be inserted here
|
||||
! We may have a new heir
|
||||
|
||||
! Read the executing and heir
|
||||
ld [%g6 + PER_CPU_OFFSET_EXECUTING], %g1
|
||||
ld [%g6 + PER_CPU_OFFSET_HEIR], %g2
|
||||
|
||||
! Update the executing only if necessary to avoid cache line
|
||||
! monopolization.
|
||||
cmp %g1, %g2
|
||||
beq try_update_is_executing
|
||||
mov 1, %g1
|
||||
|
||||
! Calculate the heir context pointer
|
||||
sub %o1, %g1, %g1
|
||||
add %g1, %g2, %o1
|
||||
|
||||
Reference in New Issue
Block a user