31 pr_emerg(
"failed to allocate process for fork");
37 pr_demph(process,
"process %d forked to %d", parent->
pid, child_p->pid);
48 default:
mos_panic(
"unknown vmap");
break;
52 if (child_vmap.
isErr())
58 (
void *) child_vmap.
get());
70 child_p->files[i].io =
io_ref(file.
io);
71 child_p->files[i].flags = file.
flags;
81 pr_dinfo2(process,
"fork: thread %d->%d", parent_thread->tid, child_t->tid);
82 child_t->u_stack = parent_thread->u_stack;
83 child_t->name = parent_thread->name;
87 child_t->signal_info.mask = parent_thread->signal_info.mask;
92 new_sig->
signal = sig->signal;
#define MOS_PROCESS_MAX_OPEN_FILES
#define MOS_STACK_PAGES_KERNEL
PtrResult< vmap_t > cow_clone_vmap_locked(MMContext *target_mmctx, vmap_t *source_vmap)
Copy-on-write a page range.
Process * process_do_fork(Process *parent)
dentry_t * dentry_ref_up_to(dentry_t *dentry, dentry_t *root)
Increment the reference count of a dentry up to a given dentry.
MOSAPI void stack_init(downwards_stack_t *stack, void *mem_region_bottom, size_t size)
MOSAPI void linked_list_init(list_node_t *head_node)
Initialise a circular double linked list.
#define list_foreach(t, v, h)
Iterate over a list.
#define list_node(element)
Get the ‘list_node’ of a list element. This is exactly the reverse of ‘list_entry’ above.
MOSAPI void list_node_prepend(list_node_t *head, list_node_t *item)
#define phyframe_va(frame)
void mm_lock_ctx_pair(MMContext *ctx1, MMContext *ctx2)
Lock and unlock a pair of MMContext objects.
void vmap_finalise_init(vmap_t *vmap, vmap_content_t content, vmap_type_t type)
Finalize the initialization of a vmap object.
void mm_unlock_ctx_pair(MMContext *ctx1, MMContext *ctx2)
phyframe_t * mm_get_free_pages(size_t npages)
PtrResult< vmap_t > mm_clone_vmap_locked(vmap_t *src_vmap, MMContext *dst_ctx)
Remap a block of virtual memory from one page table to another, i.e. copy the mappings.
__nodiscard bool io_valid(const io_t *io)
T * create(Args &&...args)
#define mos_panic(fmt,...)
#define pr_emerg(fmt,...)
#define pr_demph(feat, fmt,...)
#define pr_dinfo2(feat, fmt,...)
should_inline bool process_is_valid(const Process *process)
const char * get_vmap_type_str(vmap_type_t type)
mos::HashMap< pid_t, Process * > ProcessTable
void scheduler_add_thread(Thread *thread)
Add a thread to the scheduler, so that it can be scheduled.
#define spinlock_acquire(lock)
#define spinlock_release(lock)
static Process * New(Process *parent, mos::string_view name)
process_signal_info_t signal_info
signal handling info
dentry_t * working_directory
fd_type files[MOS_PROCESS_MAX_OPEN_FILES]
Thread * thread_allocate(Process *owner, thread_mode tflags)
Thread * thread_complete_init(Thread *thread)
void waitlist_init(waitlist_t *list)