aboutsummaryrefslogtreecommitdiffstats
path: root/src/chthreads.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/chthreads.c')
-rw-r--r--src/chthreads.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/chthreads.c b/src/chthreads.c
index 608dabe89..28b276db5 100644
--- a/src/chthreads.c
+++ b/src/chthreads.c
@@ -100,6 +100,27 @@ Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace,
return tp;
}
+/**
+ * Changes the thread priority, reschedules if necessary.
+ * @param newprio the new priority of the invoking thread
+ */
+void chThdSetPriority(t_prio newprio) {
+
+ chSysLock();
+
+#ifdef CH_USE_RT_SEMAPHORES
+ if (currp->p_rtcnt)
+ currp->p_prio = newprio + MEPRIO;
+ else
+ currp->p_prio = newprio;
+#else
+ currp->p_prio = newprio;
+#endif
+ chSchRescheduleI();
+
+ chSysUnlock();
+}
+
#ifdef CH_USE_RESUME
/**
* Resumes a thread created with the \p P_SUSPENDED option.