Owners manual

System
H3 Datasheet(Revision1.2) Copyrigh 2015 Allwinner Technology Co.,Ltd.All Rights Reserved. Page 221
4.14. Spinlock
4.14.1. Overview
Spinlock provides hardware assistance for synchronizing the processes running on multiple processors in the device.
The SpinLock module implements thirty-two 32-bit spinlocks (or hardware semaphores), which provide an efficient way
to perform a lock operation of a device resource using a single read access, thus avoiding the need for a
‘read-modify-write’ bus transfer that not all the programmable cores are capable of.
Spinlocks are present to solve the need for synchronization and mutual exclusion between heterogeneous processors
and those not operating under a single, shared operating system. There is no alternative mechanism to accomplish
these operations between processors in separate subsystems. However, Spinlocks do not solve all system
synchronization issues. They have limited applicability and should be used with care to implement higher level
synchronization protocols.
A spinlock is appropriate for mutual exclusion for access to a shared data structure. It should be used only when:
1) The time to hold the lock is predictable and small (for example, a maximum hold time of less than 200 CPU cycles
may be acceptable).
2) The locking task cannot be preempted, suspended, or interrupted while holding the lock (this would make the hold
time large and unpredictable).
3) The lock is lightly contended, that is the chance of any other process (or processor) trying to acquire the lock while
it is held is small.
If the conditions are not met, then a spinlock is not a good candidate. One alternative is to use a spinlock for critical
section control (engineered to meet the conditions) to implement a higher level semaphore that can support
preemption, notification, timeout or other higher level properties.
The Spinlock includes the following features:
Spinlock module includes 32 spinlocks
Two kinds of status of lock register: TAKEN and NOT TAKEN
confidential