Skip to content

Commit

Permalink
<HELIOS> Fix mutex logic
Browse files Browse the repository at this point in the history
Issue: #184

- Fix lock and creation logic.
- Use a definition instead for init_val.

Signed-off-by: Dybios <[email protected]>
  • Loading branch information
Dybios authored and pranjalchanda08 committed Feb 27, 2023
1 parent 3bf689e commit d54b30f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/visor/terravisor/services/kernel/helios_mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ status_t helios_mutex_lock (helios_mutex_t * mutex_ptr, size_t wait_ticks)

if ((mutex_ptr->mutex_val != MUTEX_INIT_VAL) && (mutex_ptr->lock_task != HELIOS_NULL_PTR))
{
/* If mutex is not free and if the lock task is not NULL. */
if (wait_ticks == false) /* ||_IS_ISR */
{
HELIOS_ERR("Mutex already locked");
Expand All @@ -88,13 +89,12 @@ status_t helios_mutex_lock (helios_mutex_t * mutex_ptr, size_t wait_ticks)
}
else
{
/* Set locking task as current task and acquire lock. */
mutex_ptr->lock_task = g_sched_ctrl.curr_task;
lock_flag = true;
}

if (lock_flag) {
/* Decrement and lock the mutex */
/* Set locking task as current task and acquire lock. */
mutex_ptr->lock_task = g_sched_ctrl.curr_task;
mutex_ptr->mutex_val--;
}
return success;
Expand Down

0 comments on commit d54b30f

Please sign in to comment.