mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-31 06:28:22 +00:00
semaphore: don't sleep if theres no thread running on the cpu yet
This commit is contained in:
@@ -30,6 +30,11 @@ static thread_t *get(semaphore_t *sem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int semaphore_wait(semaphore_t *sem, bool interruptible) {
|
int semaphore_wait(semaphore_t *sem, bool interruptible) {
|
||||||
|
if (_cpu()->thread == NULL) {
|
||||||
|
while (semaphore_test(sem) == false) CPU_PAUSE();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool intstate = interrupt_set(false);
|
bool intstate = interrupt_set(false);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
spinlock_acquire(&sem->lock);
|
spinlock_acquire(&sem->lock);
|
||||||
|
|||||||
Reference in New Issue
Block a user