+#if CONFIG_KERN_PRI
+/**
+ * Change the scheduling priority of a process.
+ *
+ * Process piorities are signed ints, whereas a larger integer value means
+ * higher scheduling priority. The default priority for new processes is 0.
+ * The idle process runs with the lowest possible priority: INT_MIN.
+ *
+ * A process with a higher priority always preempts lower priority processes.
+ * Processes of equal priority share the CPU time according to a simple
+ * round-robin policy.
+ *
+ * As a general rule to maximize responsiveness, compute-bound processes
+ * should be assigned negative priorities and tight, interactive processes
+ * should be assigned positive priorities.
+ *
+ * To avoid interfering with system background activities such as input
+ * processing, application processes should remain within the range -10
+ * and +10.
+ */
+void proc_setPri(struct Process *proc, int pri)
+{
+ if (proc->link.pri == pri)
+ return;
+
+ proc->link.pri = pri;
+
+ if (proc != current_process)
+ ATOMIC(sched_reenqueue(proc));
+}
+#endif // CONFIG_KERN_PRI
+
+INLINE void proc_run(void)
+{
+ void (*entry)(void) = current_process->user_entry;
+
+ LOG_INFO("New process starting at %p", entry);
+ entry();
+}
+
+/**
+ * Entry point for all the processes.
+ */
+void proc_entry(void)
+{
+ /*
+ * Return from a context switch assumes interrupts are disabled, so
+ * we need to explicitly re-enable them as soon as possible.
+ */
+ IRQ_ENABLE;
+ /* Call the actual process's entry point */
+ proc_run();
+ proc_exit();
+}
+