projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
proc: change proc_yield() behaviour.
[bertos.git]
/
bertos
/
kern
/
coop.c
diff --git
a/bertos/kern/coop.c
b/bertos/kern/coop.c
index 542ed67844a7dc0acddb63196369c68572a50c31..c5cab0ed2e4475ab1d192f897921edd139d4e1b0 100644
(file)
--- a/
bertos/kern/coop.c
+++ b/
bertos/kern/coop.c
@@
-59,6
+59,15
@@
void coop_yield(void);
void coop_switch(void);
void coop_wakeup(Process *proc);
void coop_switch(void);
void coop_wakeup(Process *proc);
+static void coop_switchTo(Process *proc)
+{
+ Process *old_process = current_process;
+
+ SCHED_ENQUEUE(current_process);
+ current_process = proc;
+ proc_switchTo(current_process, old_process);
+}
+
/**
* Give the control of the CPU to another process.
*
/**
* Give the control of the CPU to another process.
*
@@
-82,13
+91,7
@@
void coop_wakeup(Process *proc)
IRQ_ASSERT_DISABLED();
if (prio_proc(proc) >= prio_curr())
IRQ_ASSERT_DISABLED();
if (prio_proc(proc) >= prio_curr())
- {
- Process *old_process = current_process;
-
- SCHED_ENQUEUE(current_process);
- current_process = proc;
- proc_switchTo(current_process, old_process);
- }
+ coop_switchTo(proc);
else
SCHED_ENQUEUE_HEAD(proc);
}
else
SCHED_ENQUEUE_HEAD(proc);
}
@@
-98,6
+101,11
@@
void coop_wakeup(Process *proc)
*/
void coop_yield(void)
{
*/
void coop_yield(void)
{
- ATOMIC(SCHED_ENQUEUE(current_process));
- coop_switch();
+ Process *proc;
+
+ IRQ_DISABLE;
+ proc = (struct Process *)list_remHead(&proc_ready_list);
+ if (proc)
+ coop_switchTo(proc);
+ IRQ_ENABLE;
}
}