]> Johnzone git - FakeRadio.git/commitdiff
small changes to mutex, maybe lock in isrs
authorJohn Janus <mail@johnzone.org>
Mon, 28 Aug 2017 09:46:50 +0000 (11:46 +0200)
committerJohn Janus <mail@johnzone.org>
Mon, 28 Aug 2017 09:46:50 +0000 (11:46 +0200)
simple_try.c

index 1f05c6e9e8c7019f23c3b0f55f4898dcc635c220..f3a0e2114607a5a5204558d8cf631bf1ca3cad8e 100644 (file)
@@ -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);