Skip to content
Snippets Groups Projects
Commit 32f918ab authored by Oleg Hahm's avatar Oleg Hahm
Browse files

simplified sched_switch

sched_switch can check ISR itself.
parent 24f5ec92
Branches
No related tags found
No related merge requests found
...@@ -55,9 +55,8 @@ void sched_set_status(tcb_t *process, unsigned int status); ...@@ -55,9 +55,8 @@ void sched_set_status(tcb_t *process, unsigned int status);
* *
* @param[in] current_prio The priority of the current thread * @param[in] current_prio The priority of the current thread
* @param[in] other_prio The priority of the target thread * @param[in] other_prio The priority of the target thread
* @param[in] in_isr 1 if currently in interrupt context, 0 otherwise
*/ */
void sched_switch(uint16_t current_prio, uint16_t other_prio, int in_isr); void sched_switch(uint16_t current_prio, uint16_t other_prio);
/** /**
* @brief Call context switching at task exit * @brief Call context switching at task exit
......
...@@ -108,7 +108,7 @@ void mutex_unlock(struct mutex_t *mutex) ...@@ -108,7 +108,7 @@ void mutex_unlock(struct mutex_t *mutex)
DEBUG("%s: waking up waiter.\n", process->name); DEBUG("%s: waking up waiter.\n", process->name);
sched_set_status(process, STATUS_PENDING); sched_set_status(process, STATUS_PENDING);
sched_switch(active_thread->priority, process->priority, inISR()); sched_switch(active_thread->priority, process->priority);
} }
else { else {
mutex->val = 0; mutex->val = 0;
......
...@@ -171,8 +171,10 @@ void sched_set_status(tcb_t *process, unsigned int status) ...@@ -171,8 +171,10 @@ void sched_set_status(tcb_t *process, unsigned int status)
process->status = status; process->status = status;
} }
void sched_switch(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 = inISR();
DEBUG("%s: %i %i %i\n", active_thread->name, (int)current_prio, (int)other_prio, 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 (current_prio >= other_prio) {
......
...@@ -152,7 +152,7 @@ int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, void *(*sta ...@@ -152,7 +152,7 @@ int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, void *(*sta
return -1; return -1;
} }
sched_switch(active_thread->priority, PRIORITY_MAIN, inISR()); sched_switch(active_thread->priority, PRIORITY_MAIN);
return 0; return 0;
} }
......
...@@ -145,7 +145,7 @@ int sem_post(sem_t *sem) ...@@ -145,7 +145,7 @@ int sem_post(sem_t *sem)
tcb_t *next_process = (tcb_t*) next->data; tcb_t *next_process = (tcb_t*) next->data;
DEBUG("%s: waking up %s\n", active_thread->name, next_process->name); DEBUG("%s: waking up %s\n", active_thread->name, next_process->name);
sched_set_status(next_process, STATUS_PENDING); sched_set_status(next_process, STATUS_PENDING);
sched_switch(active_thread->priority, next_process->priority, inISR()); sched_switch(active_thread->priority, next_process->priority);
} }
restoreIRQ(old_state); restoreIRQ(old_state);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment