Skip to content
Snippets Groups Projects
Commit e5d61428 authored by René Kijewski's avatar René Kijewski
Browse files

core: simplify mutex signatures

parent 0e1d7c80
No related branches found
No related tags found
No related merge requests found
......@@ -50,7 +50,7 @@ typedef struct mutex_t {
*
* @return Always returns 1, always succeeds.
*/
int mutex_init(struct mutex_t *mutex);
int mutex_init(mutex_t *mutex);
/**
......@@ -62,32 +62,28 @@ int mutex_init(struct mutex_t *mutex);
* @return 1 if mutex was unlocked, now it is locked.
* @return 0 if the mutex was locked.
*/
int mutex_trylock(struct mutex_t *mutex);
int mutex_trylock(mutex_t *mutex);
/**
* @brief Tries to get a mutex, blocking.
* @brief Locks a mutex, blocking.
*
* @param[in] mutex Mutex object to lock. Has to be initialized first. Must not
* be NULL.
*
* @return 1 getting the mutex was successful
* @return <1 there was an error.
* @param[in] mutex Mutex object to lock. Has to be initialized first. Must not be NULL.
*/
int mutex_lock(struct mutex_t *mutex);
void mutex_lock(mutex_t *mutex);
/**
* @brief Unlocks the mutex.
*
* @param[in] mutex Mutex object to unlock, must not be NULL.
*/
void mutex_unlock(struct mutex_t *mutex);
void mutex_unlock(mutex_t *mutex);
/**
* @brief Unlocks the mutex and sends the current thread to sleep
*
* @param[in] mutex Mutex object to unlock, must not be NULL.
*/
void mutex_unlock_and_sleep(struct mutex_t *mutex);
void mutex_unlock_and_sleep(mutex_t *mutex);
#endif /* __MUTEX_H_ */
/** @} */
......@@ -35,15 +35,13 @@
static void mutex_wait(struct mutex_t *mutex);
int mutex_init(struct mutex_t *mutex)
void mutex_init(struct mutex_t *mutex)
{
mutex->val = 0;
mutex->queue.priority = 0;
mutex->queue.data = 0;
mutex->queue.next = NULL;
return 1;
}
int mutex_trylock(struct mutex_t *mutex)
......@@ -52,7 +50,7 @@ int mutex_trylock(struct mutex_t *mutex)
return (atomic_set_return(&mutex->val, 1) == 0);
}
int mutex_lock(struct mutex_t *mutex)
void mutex_lock(struct mutex_t *mutex)
{
DEBUG("%s: trying to get mutex. val: %u\n", sched_active_thread->name, mutex->val);
......@@ -60,8 +58,6 @@ int mutex_lock(struct mutex_t *mutex)
/* mutex was locked. */
mutex_wait(mutex);
}
return 1;
}
static void mutex_wait(struct mutex_t *mutex)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment