forked from xuos/xiuos
Fix a semaphore.c bug
This commit is contained in:
parent
6d4cef4358
commit
d05754a98e
|
@ -35,7 +35,7 @@ INC_DIR = -I$(KERNEL_ROOT)/services/shell/letter-shell \
|
|||
ifeq ($(BOARD), imx6q-sabrelite)
|
||||
all: init test_fault simple_client simple_server shell fs_server semaphore_server test_semaphore test_ipc_null test_thread test_irq_hdlr test_irq_block test_irq_send eth_driver epit_server readme.txt | bin
|
||||
else
|
||||
all: init test_fault simple_client simple_server shell fs_server test_ipc_null test_thread test_semaphore readme.txt | bin
|
||||
all: init test_fault simple_client simple_server shell fs_server semaphore_server test_ipc_null test_thread test_semaphore readme.txt | bin
|
||||
endif
|
||||
../tools/mkfs/mkfs ./fs.img $^
|
||||
@mv $(filter-out readme.txt, $^) bin
|
||||
|
|
|
@ -66,6 +66,7 @@ int main(int argc, char** argv)
|
|||
|
||||
printf("test thread sum after %d signal: 0x%x\n", NR_THREADS, sum);
|
||||
|
||||
semaphore_free(sem_id);
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -35,11 +35,11 @@ static inline struct ksemaphore* ksemaphore_get_by_id(struct XiziSemaphorePool*
|
|||
DOUBLE_LIST_FOR_EACH_ENTRY(sem, &sem_pool->sem_list_guard, sem_list_node)
|
||||
{
|
||||
if (sem->id == sem_id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sem;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ksemaphore_alloc(struct XiziSemaphorePool* sem_pool, int val)
|
||||
{
|
||||
|
@ -102,8 +102,9 @@ bool ksemaphore_signal(struct XiziSemaphorePool* sem_pool, uint32_t sem_id)
|
|||
|
||||
if (sem->val < 0) {
|
||||
if (!IS_DOUBLE_LIST_EMPTY(&sem->wait_list_guard)) {
|
||||
assert(sem->wait_list_guard.next != NULL);
|
||||
xizi_task_manager.task_unblock(CONTAINER_OF(sem->wait_list_guard.next, struct Thread, node));
|
||||
struct Thread* thd = CONTAINER_OF(sem->wait_list_guard.next, struct Thread, node);
|
||||
assert(thd != NULL && thd->state == BLOCKED);
|
||||
xizi_task_manager.task_unblock(thd);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue