Browse Source

* some more mutex related changes

dev/timer
Kaspar Schleiser 12 years ago
parent
commit
0441c5a4a4
  1. 2
      core/include/sched.h
  2. 4
      core/mutex.c
  3. 5
      core/sched.c

2
core/include/sched.h

@ -25,7 +25,7 @@ void sched_init();
void sched_run();
void sched_set_status(tcb *process, unsigned int status);
void sched_switch_if_higher(uint16_t current_prio, uint16_t other_prio, int in_isr);
void sched_switch(uint16_t current_prio, uint16_t other_prio, int in_isr);
volatile unsigned int sched_context_switch_request;

4
core/mutex.c

@ -68,7 +68,7 @@ void mutex_wait(struct mutex_t *mutex) {
n.data = (unsigned int) active_thread;
n.next = NULL;
DEBUG("%s: Adding node to mutex queue: prio: %u data: %u\n", active_thread->name, n.priority, n.data);
DEBUG("%s: Adding node to mutex queue: prio: %u\n", active_thread->name, n.priority);
queue_priority_add(&(mutex->queue), &n);
@ -90,7 +90,7 @@ void mutex_unlock(struct mutex_t* mutex, int yield) {
DEBUG("%s: waking up waiter %s.\n", process->name);
sched_set_status(process, STATUS_PENDING);
sched_switch_if_higher(active_thread->priority, process->priority, inISR());
sched_switch(active_thread->priority, process->priority, inISR());
} else {
mutex->val = 0;
}

5
core/sched.c

@ -143,8 +143,9 @@ void sched_set_status(tcb *process, unsigned int status) {
process->status = status;
}
void sched_switch_if_higher(uint16_t current_prio, uint16_t other_prio, int in_isr) {
if (current_prio < other_prio) {
void sched_switch(uint16_t current_prio, uint16_t other_prio, int in_isr) {
DEBUG("%s: %i %i %i\n", active_thread->name, (int)current_prio, (int)other_prio, in_isr);
if (current_prio <= other_prio) {
if (in_isr) {
sched_context_switch_request = 1;
} else {

Loading…
Cancel
Save