Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
e5d61428
Commit
e5d61428
authored
10 years ago
by
René Kijewski
Browse files
Options
Downloads
Patches
Plain Diff
core: simplify mutex signatures
parent
0e1d7c80
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/include/mutex.h
+7
-11
7 additions, 11 deletions
core/include/mutex.h
core/mutex.c
+2
-6
2 additions, 6 deletions
core/mutex.c
with
9 additions
and
17 deletions
core/include/mutex.h
+
7
−
11
View file @
e5d61428
...
@@ -50,7 +50,7 @@ typedef struct mutex_t {
...
@@ -50,7 +50,7 @@ typedef struct mutex_t {
*
*
* @return Always returns 1, always succeeds.
* @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);
...
@@ -62,32 +62,28 @@ int mutex_init(struct mutex_t *mutex);
* @return 1 if mutex was unlocked, now it is locked.
* @return 1 if mutex was unlocked, now it is locked.
* @return 0 if the mutex was 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
* @param[in] mutex Mutex object to lock. Has to be initialized first. Must not be NULL.
* be NULL.
*
* @return 1 getting the mutex was successful
* @return <1 there was an error.
*/
*/
int
mutex_lock
(
struct
mutex_t
*
mutex
);
void
mutex_lock
(
mutex_t
*
mutex
);
/**
/**
* @brief Unlocks the mutex.
* @brief Unlocks the mutex.
*
*
* @param[in] mutex Mutex object to unlock, must not be NULL.
* @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
* @brief Unlocks the mutex and sends the current thread to sleep
*
*
* @param[in] mutex Mutex object to unlock, must not be NULL.
* @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_ */
#endif
/* __MUTEX_H_ */
/** @} */
/** @} */
This diff is collapsed.
Click to expand it.
core/mutex.c
+
2
−
6
View file @
e5d61428
...
@@ -35,15 +35,13 @@
...
@@ -35,15 +35,13 @@
static
void
mutex_wait
(
struct
mutex_t
*
mutex
);
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
->
val
=
0
;
mutex
->
queue
.
priority
=
0
;
mutex
->
queue
.
priority
=
0
;
mutex
->
queue
.
data
=
0
;
mutex
->
queue
.
data
=
0
;
mutex
->
queue
.
next
=
NULL
;
mutex
->
queue
.
next
=
NULL
;
return
1
;
}
}
int
mutex_trylock
(
struct
mutex_t
*
mutex
)
int
mutex_trylock
(
struct
mutex_t
*
mutex
)
...
@@ -52,7 +50,7 @@ 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
);
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
);
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)
...
@@ -60,8 +58,6 @@ int mutex_lock(struct mutex_t *mutex)
/* mutex was locked. */
/* mutex was locked. */
mutex_wait
(
mutex
);
mutex_wait
(
mutex
);
}
}
return
1
;
}
}
static
void
mutex_wait
(
struct
mutex_t
*
mutex
)
static
void
mutex_wait
(
struct
mutex_t
*
mutex
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment