Ejemplo n.º 1
0
/**
 * 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 CONFIG_KERN_PRI_INHERIT
	int new_pri;

	/*
	 * Whatever it will happen below, this is the new
	 * original priority of the process, i.e., the priority
	 * it has without taking inheritance under account.
	 */
	proc->orig_pri = pri;

	/* If not changing anything we can just leave */
	if ((new_pri = __prio_proc(proc)) == proc->link.pri)
		return;

	/*
	 * Actual process priority is the highest among its
	 * own priority and the one of the top-priority
	 * process that it is blocking (returned by
	 * __prio_proc()).
	 */
	proc->link.pri = new_pri;
#else
	if (proc->link.pri == pri)
		return;

	proc->link.pri = pri;
#endif // CONFIG_KERN_PRI_INHERIT

	if (proc != current_process)
		ATOMIC(sched_reenqueue(proc));
}
Ejemplo n.º 2
0
/**
 * 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));
}