diff options
Diffstat (limited to 'sys/include')
-rw-r--r-- | sys/include/arch/amd64/cpu.h | 1 | ||||
-rw-r--r-- | sys/include/arch/amd64/intr.h | 1 | ||||
-rw-r--r-- | sys/include/sys/proc.h | 14 | ||||
-rw-r--r-- | sys/include/sys/spawn.h | 2 | ||||
-rw-r--r-- | sys/include/sys/syscall.h | 1 | ||||
-rw-r--r-- | sys/include/sys/wait.h | 37 |
6 files changed, 54 insertions, 2 deletions
diff --git a/sys/include/arch/amd64/cpu.h b/sys/include/arch/amd64/cpu.h index a047cef..046b621 100644 --- a/sys/include/arch/amd64/cpu.h +++ b/sys/include/arch/amd64/cpu.h @@ -46,6 +46,7 @@ struct cpu_info { uint32_t apicid; uint32_t feat; + uint8_t id; /* MI Logical ID */ uint8_t model : 4; /* CPU model number */ uint8_t family : 4; /* CPU family ID */ uint8_t has_x2apic : 1; diff --git a/sys/include/arch/amd64/intr.h b/sys/include/arch/amd64/intr.h index 1877d20..3870f18 100644 --- a/sys/include/arch/amd64/intr.h +++ b/sys/include/arch/amd64/intr.h @@ -35,6 +35,7 @@ #define IST_SCHED 1U #define IST_HW_IRQ 2U #define IST_SW_INT 3U +#define IST_SYSCALL 4U /* Upper 4 bits of interrupt vector */ #define IPL_SHIFT 4 diff --git a/sys/include/sys/proc.h b/sys/include/sys/proc.h index decc615..9cc9238 100644 --- a/sys/include/sys/proc.h +++ b/sys/include/sys/proc.h @@ -74,6 +74,14 @@ struct __packed coredump { uint32_t checksum; }; +/* + * Sometimes we may need to pin a process + * to a specific CPU. This type represents + * the (machine independent) logical processor + * ID for a process to be pinned to. + */ +typedef int16_t affinity_t; + struct proc { pid_t pid; struct exec_prog exec; @@ -86,6 +94,7 @@ struct proc { struct trapframe tf; struct pcb pcb; struct proc *parent; + affinity_t affinity; void *data; size_t priority; int exit_status; @@ -107,10 +116,14 @@ struct proc { #define PROC_WAITED BIT(4) /* Being waited on by parent */ #define PROC_KTD BIT(5) /* Kernel thread */ #define PROC_SLEEP BIT(6) /* Thread execution paused */ +#define PROC_PINNED BIT(7) /* Pinned to CPU */ struct proc *this_td(void); struct proc *get_child(struct proc *cur, pid_t pid); +void proc_pin(struct proc *td, affinity_t cpu); +void proc_unpin(struct proc *td); + void proc_reap(struct proc *td); void proc_coredump(struct proc *td, uintptr_t fault_addr); @@ -119,6 +132,7 @@ pid_t getppid(void); scret_t sys_getpid(struct syscall_args *scargs); scret_t sys_getppid(struct syscall_args *scargs); +scret_t sys_waitpid(struct syscall_args *scargs); int md_spawn(struct proc *p, struct proc *parent, uintptr_t ip); diff --git a/sys/include/sys/spawn.h b/sys/include/sys/spawn.h index 0c54e4c..28dbe5b 100644 --- a/sys/include/sys/spawn.h +++ b/sys/include/sys/spawn.h @@ -33,8 +33,6 @@ #include <sys/types.h> #include <sys/param.h> -#define SPAWN_WAIT BIT(0) - #if !defined(_KERNEL) pid_t spawn(const char *pathname, char **argv, char **envp, int flags); #endif /* _KERNEL */ diff --git a/sys/include/sys/syscall.h b/sys/include/sys/syscall.h index 51c2579..02629a9 100644 --- a/sys/include/sys/syscall.h +++ b/sys/include/sys/syscall.h @@ -58,6 +58,7 @@ #define SYS_getppid 17 #define SYS_setuid 18 #define SYS_getuid 19 +#define SYS_waitpid 20 #if defined(_KERNEL) /* Syscall return value and arg type */ diff --git a/sys/include/sys/wait.h b/sys/include/sys/wait.h new file mode 100644 index 0000000..07a2d4e --- /dev/null +++ b/sys/include/sys/wait.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Hyra nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_WAIT_H_ +#define _SYS_WAIT_H_ + +#include <sys/types.h> + +pid_t waitpid(pid_t pid, int *wstatus, int options); + +#endif /* !_SYS_WAIT_H_ */ |