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
3f95d728
Commit
3f95d728
authored
11 years ago
by
Oleg Hahm
Browse files
Options
Downloads
Patches
Plain Diff
fix for #25 by using mutexes for hwtimer_wait
parent
da7e0988
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/hwtimer.c
+15
-5
15 additions, 5 deletions
core/hwtimer.c
with
15 additions
and
5 deletions
core/hwtimer.c
+
15
−
5
View file @
3f95d728
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* @author Heiko Will <hwill@inf.fu-berlin.de>
* @author Heiko Will <hwill@inf.fu-berlin.de>
* @author Thomas Hillebrandt <hillebra@inf.fu-berlin.de>
* @author Thomas Hillebrandt <hillebra@inf.fu-berlin.de>
* @author Kaspar Schleiser <kaspar.schleiser@fu-berlin.de>
* @author Kaspar Schleiser <kaspar.schleiser@fu-berlin.de>
* @author Oliver Hahm <oliver.hahm@fu-berlin.de>
* @}
* @}
*/
*/
...
@@ -45,6 +46,10 @@ static void multiplexer(int source)
...
@@ -45,6 +46,10 @@ static void multiplexer(int source)
timer
[
source
].
callback
(
timer
[
source
].
data
);
timer
[
source
].
callback
(
timer
[
source
].
data
);
}
}
static
void
hwtimer_releasemutex
(
void
*
mutex
)
{
mutex_unlock
((
mutex_t
*
)
mutex
);
}
static
void
hwtimer_wakeup
(
void
*
ptr
)
static
void
hwtimer_wakeup
(
void
*
ptr
)
{
{
int
pid
=
(
int
)
ptr
;
int
pid
=
(
int
)
ptr
;
...
@@ -98,20 +103,25 @@ unsigned long hwtimer_now(void)
...
@@ -98,20 +103,25 @@ unsigned long hwtimer_now(void)
void
hwtimer_wait
(
unsigned
long
ticks
)
void
hwtimer_wait
(
unsigned
long
ticks
)
{
{
mutex_t
mutex
;
if
(
ticks
<=
6
||
inISR
())
{
if
(
ticks
<=
6
||
inISR
())
{
hwtimer_spin
(
ticks
);
hwtimer_spin
(
ticks
);
return
;
return
;
}
}
mutex_init
(
&
mutex
);
mutex_lock
(
&
mutex
);
/* -2 is to adjust the real value */
/* -2 is to adjust the real value */
int
res
=
hwtimer_set
(
ticks
-
2
,
hwtimer_wakeup
,
(
void
*
)(
unsigned
int
)(
active_thread
->
pid
));
int
res
=
hwtimer_set
(
ticks
-
2
,
hwtimer_releasemutex
,
&
mutex
);
if
(
res
==
-
1
)
{
if
(
res
==
-
1
)
{
mutex_unlock
(
&
mutex
);
hwtimer_spin
(
ticks
);
hwtimer_spin
(
ticks
);
return
;
return
;
}
}
thread_sleep
();
/* try to lock mutex again will cause the thread to go into
* STATUS_MUTEX_BLOCKED until hwtimer fires the releasemutex */
mutex_lock
(
&
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