From: Minep Date: Wed, 15 Jun 2022 20:55:55 +0000 (+0100) Subject: Merge branch 'master' into signal-dev X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/commitdiff_plain/509574b18a3373030cd0d7b979499499ff06dd9b?ds=sidebyside;hp=-c Merge branch 'master' into signal-dev --- 509574b18a3373030cd0d7b979499499ff06dd9b diff --combined lunaix-os/includes/lunaix/process.h index e429060,32b74df..28cb76b --- a/lunaix-os/includes/lunaix/process.h +++ b/lunaix-os/includes/lunaix/process.h @@@ -4,7 -4,6 +4,7 @@@ #include #include #include +#include #include #include #include @@@ -27,32 -26,21 +27,34 @@@ struct proc_m struct mm_region* regions; }; +struct proc_sig +{ + void* signal_handler; + int sig_num; + isr_param prev_context; +}; + +#define PROC_SIG_SIZE sizeof(struct proc_sig) // size=84 + struct proc_info { pid_t pid; struct proc_info* parent; - isr_param intr_ctx; + isr_param intr_ctx; // size=76 + uintptr_t ustack_top; struct llist_header siblings; struct llist_header children; + struct llist_header grp_member; struct proc_mm mm; void* page_table; time_t created; uint8_t state; int32_t exit_code; int32_t k_status; + sigset_t sig_pending; + sigset_t sig_mask; + void* sig_handler[_SIG_NUM]; + pid_t pgid; struct lx_timer* timer; }; diff --combined lunaix-os/includes/lunaix/syscall.h index 9cb7764,37aa852..3a6e2eb --- a/lunaix-os/includes/lunaix/syscall.h +++ b/lunaix-os/includes/lunaix/syscall.h @@@ -13,10 -13,6 +13,10 @@@ #define __SYSCALL__exit 8 #define __SYSCALL_wait 9 #define __SYSCALL_waitpid 10 +#define __SYSCALL_sigreturn 11 +#define __SYSCALL_sigprocmask 12 +#define __SYSCALL_signal 13 +#define __SYSCALL_pause 14 #define __SYSCALL_MAX 0x100 @@@ -24,12 -20,6 +24,6 @@@ void syscall_install(); - static void* - syscall(unsigned int callcode) - { - asm volatile("int %0" ::"i"(LUNAIX_SYS_CALL), "D"(callcode) : "eax"); - } - #define asmlinkage __attribute__((regparm(0))) #define __PARAM_MAP1(t1, p1) t1 p1 @@@ -56,7 -46,7 +50,7 @@@ asmlinkage rettype __lxsys_##name(__PARAM_MAP3(t1, p1, t2, p2, t3, p3)) #define __DEFINE_LXSYSCALL4(rettype, name, t1, p1, t2, p2, t3, p3, t4, p4) \ - asmlinkage rettype __lxsys_##nam( \ + asmlinkage rettype __lxsys_##name( \ __PARAM_MAP4(t1, p1, t2, p2, t3, p3, t4, p4)) #define __LXSYSCALL(rettype, name) \ diff --combined lunaix-os/kernel/sched.c index 7f124c4,e7bcd9a..8e5eecb --- a/lunaix-os/kernel/sched.c +++ b/lunaix-os/kernel/sched.c @@@ -1,14 -1,12 +1,14 @@@ #include #include + #include #include + #include #include #include #include - +#include #include #include #include @@@ -60,8 -58,6 +60,8 @@@ run(struct proc_info* proc apic_done_servicing(); + signal_dispatch(); + asm volatile("pushl %0\n" "jmp soft_iret\n" ::"r"(&__current->intr_ctx) : "memory"); @@@ -149,11 -145,12 +149,12 @@@ _wait(pid_t wpid, int* status, int opti return -1; } + wpid = wpid ? wpid : -__current->pgid; cpu_enable_interrupt(); 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; @@@ -209,8 -206,10 +210,10 @@@ push_process(struct proc_info* process 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->grp_member); + // every process is the child of first process (pid=1) if (process->parent) { llist_append(&process->parent->children, &process->siblings);