git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into signal-dev
[lunaix-os.git]
/
lunaix-os
/
kernel
/
sched.c
diff --git
a/lunaix-os/kernel/sched.c
b/lunaix-os/kernel/sched.c
index 35e3cff5c69f2a6164a40009cc48d560eb3e1bc5..026fb515a8dbfbc34410e868de18ccad40b7b308 100644
(file)
--- a/
lunaix-os/kernel/sched.c
+++ b/
lunaix-os/kernel/sched.c
@@
-1,12
+1,14
@@
#include <arch/x86/interrupts.h>
#include <arch/x86/tss.h>
#include <arch/x86/interrupts.h>
#include <arch/x86/tss.h>
+
#include <hal/apic.h>
#include <hal/cpu.h>
#include <hal/apic.h>
#include <hal/cpu.h>
+
#include <lunaix/mm/kalloc.h>
#include <lunaix/mm/vmm.h>
#include <lunaix/process.h>
#include <lunaix/sched.h>
#include <lunaix/mm/kalloc.h>
#include <lunaix/mm/vmm.h>
#include <lunaix/process.h>
#include <lunaix/sched.h>
-
+#include <lunaix/signal.h>
#include <lunaix/spike.h>
#include <lunaix/status.h>
#include <lunaix/syscall.h>
#include <lunaix/spike.h>
#include <lunaix/status.h>
#include <lunaix/syscall.h>
@@
-58,9
+60,11
@@
run(struct proc_info* proc)
apic_done_servicing();
apic_done_servicing();
- asm volatile("pushl %0\n"
+ signal_dispatch();
+
+ asm volatile("movl %0, %%eax\n"
"jmp soft_iret\n" ::"r"(&__current->intr_ctx)
"jmp soft_iret\n" ::"r"(&__current->intr_ctx)
- : "memory");
+ : "
eax", "
memory");
}
void
}
void
@@
-70,6
+74,8
@@
schedule()
return;
}
return;
}
+ // 上下文切换相当的敏感!我们不希望任何的中断打乱栈的顺序……
+ cpu_disable_interrupt();
struct proc_info* next;
int prev_ptr = sched_ctx.procs_index;
int ptr = prev_ptr;
struct proc_info* next;
int prev_ptr = sched_ctx.procs_index;
int ptr = prev_ptr;
@@
-81,8
+87,6
@@
schedule()
sched_ctx.procs_index = ptr;
sched_ctx.procs_index = ptr;
- // 上下文切换相当的敏感!我们不希望任何的中断打乱栈的顺序……
- cpu_disable_interrupt();
run(next);
}
run(next);
}
@@
-99,6
+103,7
@@
__DEFINE_LXSYSCALL1(unsigned int, sleep, unsigned int, seconds)
if (!seconds) {
return 0;
}
if (!seconds) {
return 0;
}
+
if (__current->timer) {
return __current->timer->counter / timer_context()->running_frequency;
}
if (__current->timer) {
return __current->timer->counter / timer_context()->running_frequency;
}
@@
-118,7
+123,7
@@
__DEFINE_LXSYSCALL1(void, exit, int, status)
__DEFINE_LXSYSCALL(void, yield)
{
__DEFINE_LXSYSCALL(void, yield)
{
- sched
_yield
();
+ sched
ule
();
}
pid_t
}
pid_t
@@
-143,10
+148,13
@@
_wait(pid_t wpid, int* status, int options)
if (llist_empty(&__current->children)) {
return -1;
}
if (llist_empty(&__current->children)) {
return -1;
}
+
+ wpid = wpid ? wpid : -__current->pgid;
+ cpu_enable_interrupt();
repeat:
llist_for_each(proc, n, &__current->children, siblings)
{
repeat:
llist_for_each(proc, n, &__current->children, siblings)
{
- if (!~wpid || proc->pid == wpid) {
+ if (!~wpid || proc->pid == wpid
|| proc->pgid == -wpid
) {
if (proc->state == PROC_TERMNAT && !options) {
status_flags |= PROCTERM;
goto done;
if (proc->state == PROC_TERMNAT && !options) {
status_flags |= PROCTERM;
goto done;
@@
-165,6
+173,7
@@
repeat:
goto repeat;
done:
goto repeat;
done:
+ cpu_disable_interrupt();
*status = (proc->exit_code & 0xffff) | status_flags;
return destroy_process(proc->pid);
}
*status = (proc->exit_code & 0xffff) | status_flags;
return destroy_process(proc->pid);
}
@@
-201,8
+210,10
@@
push_process(struct proc_info* process)
process = &sched_ctx._procs[index];
process = &sched_ctx._procs[index];
- // make sure the
address is in the range of
process table
+ // make sure the
reference is relative to
process table
llist_init_head(&process->children);
llist_init_head(&process->children);
+ llist_init_head(&process->grp_member);
+
// every process is the child of first process (pid=1)
if (process->parent) {
llist_append(&process->parent->children, &process->siblings);
// every process is the child of first process (pid=1)
if (process->parent) {
llist_append(&process->parent->children, &process->siblings);