]> rtime.felk.cvut.cz Git - fpga/rpi-motor-control.git/blobdiff - pmsm-control/test_sw/misc.c
Added testing SW in folder test_sw.
[fpga/rpi-motor-control.git] / pmsm-control / test_sw / misc.c
diff --git a/pmsm-control/test_sw/misc.c b/pmsm-control/test_sw/misc.c
new file mode 100644 (file)
index 0000000..78d4eb5
--- /dev/null
@@ -0,0 +1,28 @@
+/**
+ * \brief Implementace pomocnych funkci.
+ * \file misc.c
+ * \date Feb 1, 2015
+ * \author Martin Prudek
+ *
+ *     Implementace pomocnych funkci.
+ *     Vetsinou pro komunikaci mezi vlakny, jejich sychronizaci a predavani priorit.
+ */
+
+#include "misc.h"
+#include <sched.h>
+
+/**
+ * nastavi prioritu a scheduler podle parametru
+ * funkce na konci vrati semafor, aby mohlo dojit k opetovne zmene parametru
+ * \param pointer na struct thread_sched_param
+ */
+void set_priority(void * param){
+       struct sched_param sp;
+       struct thread_param *tp = ((struct thread_param*) param);
+
+       sp.sched_priority = tp->sch_prior; /*vysoka priorita*/
+       if(sched_setscheduler(0, tp->sch_policy, &sp) == -1) {
+               perror("pid sched_setscheduler failed");
+       }
+       sem_post(&thd_par_sem);
+}