From: John Janus Date: Mon, 28 Aug 2017 09:46:50 +0000 (+0200) Subject: small changes to mutex, maybe lock in isrs X-Git-Url: https://git.johnzone.org/?a=commitdiff_plain;h=3de9f41866cd6899b807a7dd41c3f95675734f1e;p=FakeRadio.git small changes to mutex, maybe lock in isrs --- diff --git a/simple_try.c b/simple_try.c index 1f05c6e..f3a0e21 100644 --- a/simple_try.c +++ b/simple_try.c @@ -17,7 +17,9 @@ static volatile bool running = true; static volatile bool pwrOn = false; static volatile bool chnl1 = true; +static volatile bool sthchanged = false; pthread_cond_t* wakeup; +pthread_mutex_t* mut; void ctrlCHandler(int signum) { running = false; @@ -62,7 +64,7 @@ int main(void) { pinMode(PWRLED, OUTPUT); pinMode(CHNL1LED, OUTPUT); pinMode(CHNL2LED, OUTPUT); - pthread_mutex_t* mut = malloc (sizeof(pthread_mutex_t)); + mut = malloc (sizeof(pthread_mutex_t)); pthread_mutex_init(mut, NULL); wakeup = malloc(sizeof(pthread_cond_t)); pthread_cond_init(wakeup, NULL); @@ -87,12 +89,16 @@ int main(void) { digitalWrite(CHNL2LED, LOW); digitalWrite(CHNL1LED, HIGH); } - pthread_mutex_unlock(mut) + pthread_mutex_unlock(mut); //delay(200); //sleep(0.3); } printf("ShuttingDown\n"); + pthread_cond_destroy(wakeup); + pthread_mutex_destroy(mut); + free(wakeup); + free(mut); digitalWrite(PWRLED, HIGH); digitalWrite(CHNL1LED, HIGH); digitalWrite(CHNL2LED, HIGH);