diff options
author | px4dev <px4@purgatory.org> | 2013-09-18 21:47:10 -0700 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2013-09-18 21:47:29 -0700 |
commit | 7e0da345f06babd2b99670b559c5c7faf96b6997 (patch) | |
tree | cfefda9208303483c6c958044e56aca3b494dee0 /src/modules | |
parent | 626f433630697a630e5063f4f53cfa570bb4a9df (diff) | |
download | px4-firmware-7e0da345f06babd2b99670b559c5c7faf96b6997.tar.gz px4-firmware-7e0da345f06babd2b99670b559c5c7faf96b6997.tar.bz2 px4-firmware-7e0da345f06babd2b99670b559c5c7faf96b6997.zip |
The parameter system is supposed to have a lock; implement one.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/systemlib/param/param.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/modules/systemlib/param/param.c b/src/modules/systemlib/param/param.c index e7c96fe54..2832d87ef 100644 --- a/src/modules/systemlib/param/param.c +++ b/src/modules/systemlib/param/param.c @@ -48,6 +48,7 @@ #include <unistd.h> #include <systemlib/err.h> #include <errno.h> +#include <semaphore.h> #include <sys/stat.h> @@ -95,18 +96,20 @@ ORB_DEFINE(parameter_update, struct parameter_update_s); /** parameter update topic handle */ static orb_advert_t param_topic = -1; +static sem_t param_lock = { .semcount = 1 }; + /** lock the parameter store */ static void param_lock(void) { - /* XXX */ + do {} while (sem_wait(¶m_lock) != 0); } /** unlock the parameter store */ static void param_unlock(void) { - /* XXX */ + sem_post(¶m_lock); } /** assert that the parameter store is locked */ |