Commit Graph

6 Commits

Author SHA1 Message Date
ligd 4541132035 Revert "shced:sem: replace mutex with spinlock"
Cause we can't do sem_post/wait within spinlock

This reverts commit 23d65cb97f.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-29 23:01:39 +08:00
dongjiuzhu1 2e3a6acaa2 sched/sem_rw: convert read-lock to write-lock when self already holds a write-lock
If the write lock is already held by oneself and sine the write
lock can be recursively held, so, this operation can be converted to a write
lock to avoid deadlock.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-10 16:42:15 +08:00
dongjiuzhu1 a367657d2d sched/semaphore: support recursive write for same process in sem_rw lock
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-02 01:56:46 +08:00
Alin Jerpelea eb9030c891 sched: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-09-12 01:10:14 +08:00
TaiJu Wu 23d65cb97f shced:sem: replace mutex with spinlock
The overhead of spinlok is less than mutext (mutex need to call
enter_critical section.)
After this patch, `down_write_trylock` and `down_read_trylock` can be
use in interrupt context.

The instruction is protected with mutex only one instruction so using
spinlock is better.

Signed-off-by: TaiJu Wu <tjwu1217@gmail.com>
2024-03-19 18:06:12 +08:00
chenrun1 a6dc4412ba misc/rwlock:Implementing read/write locks.
A new locking mechanism: read/write locks
When there is a writer it is not possible to put on a read lock or a write lock; when there is a reader it is possible to reenter the read lock but not the write lock.
Writers are exclusive locks, readers are shared locks.
At the same time through the waiter count to determine whether there is currently a blocked task, if there is then in the unlock time to wake up all the waiter, through the priority of the competition to complete the blocked lock execution.
For example:
When we have a reader blocking two waiter writers, when the reader is unlocked it wakes up both writers. The writer with higher priority wakes up and checks for a successful condition and locks the lock, the second writer wakes up and fails to check for a condition and continues to block the lock.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2023-12-02 19:43:19 -08:00