MOS Source Code
Loading...
Searching...
No Matches
process.c File Reference
#include "mos/tasks/process.h"
#include "mos/filesystem/sysfs/sysfs.h"
#include "mos/filesystem/sysfs/sysfs_autoinit.h"
#include "mos/io/io.h"
#include "mos/mm/mm.h"
#include "mos/tasks/signal.h"
#include <abi-bits/wait.h>
#include <errno.h>
#include <limits.h>
#include <mos/filesystem/dentry.h>
#include <mos/filesystem/fs_types.h>
#include <mos/filesystem/vfs.h>
#include <mos/lib/structures/hashmap.h>
#include <mos/lib/structures/hashmap_common.h>
#include <mos/lib/structures/list.h>
#include <mos/lib/sync/spinlock.h>
#include <mos/misc/panic.h>
#include <mos/mm/cow.h>
#include <mos/mm/paging/paging.h>
#include <mos/platform/platform.h>
#include <mos/syslog/printk.h>
#include <mos/tasks/schedule.h>
#include <mos/tasks/task_types.h>
#include <mos/tasks/thread.h>
#include <mos/tasks/wait.h>
#include <mos_stdio.h>
#include <mos_stdlib.h>
#include <mos_string.h>
+ Include dependency graph for process.c:

Go to the source code of this file.

Macros

#define do_print(fmt, name, item)
 
#define stat_line(fmt)
 

Functions

static pid_t new_process_id (void)
 
process_tprocess_allocate (process_t *parent, const char *name)
 
void process_destroy (process_t *process)
 
process_tprocess_new (process_t *parent, const char *name, const stdio_t *ios)
 
process_tprocess_get (pid_t pid)
 
fd_t process_attach_ref_fd (process_t *process, io_t *file, fd_flags_t flags)
 
io_tprocess_get_fd (process_t *process, fd_t fd)
 
bool process_detach_fd (process_t *process, fd_t fd)
 
pid_t process_wait_for_pid (pid_t pid, u32 *exit_code, u32 flags)
 
void process_exit (process_t *process, u8 exit_code, signal_t signal)
 
void process_dump_mmaps (const process_t *process)
 
bool process_register_signal_handler (process_t *process, signal_t sig, const sigaction_t *sigaction)
 
static bool process_sysfs_process_stat (sysfs_file_t *f)
 
static bool process_sysfs_thread_stat (sysfs_file_t *f)
 
static bool process_sysfs_vmap_stat (sysfs_file_t *f)
 
 SYSFS_AUTOREGISTER (current, process_sysfs_items)
 

Variables

hashmap_t process_table = { 0 }
 
static const char * vmap_content_str []
 
const char * vmap_type_str []
 
static sysfs_item_t process_sysfs_items []
 

Macro Definition Documentation

◆ do_print

#define do_print ( fmt,
name,
item )
Value:
sysfs_printf(f, "%-10s: " fmt "\n", name, item);
u32 const char * fmt
Definition assert.h:36
const char * name
Definition slab.c:31
ssize_t sysfs_printf(sysfs_file_t *file, const char *fmt,...)
Definition sysfs.c:73

Definition at line 394 of file process.c.

Referenced by process_sysfs_process_stat(), and process_sysfs_thread_stat().

◆ stat_line

#define stat_line ( fmt)
Value:
" %9s: " fmt "\n"

Referenced by process_sysfs_vmap_stat().

Function Documentation

◆ new_process_id()

static pid_t new_process_id ( void )
static

Definition at line 49 of file process.c.

Referenced by process_allocate().

◆ process_allocate()

process_t * process_allocate ( process_t * parent,
const char * name )

Definition at line 55 of file process.c.

Referenced by kthread_init(), process_do_fork(), and process_new().

+ Here is the call graph for this function:

◆ process_destroy()

void process_destroy ( process_t * process)

Definition at line 107 of file process.c.

Referenced by process_wait_for_pid().

+ Here is the call graph for this function:

◆ process_new()

process_t * process_new ( process_t * parent,
const char * name,
const stdio_t * ios )

Definition at line 143 of file process.c.

Referenced by elf_create_process().

+ Here is the call graph for this function:

◆ process_get()

process_t * process_get ( pid_t pid)

Definition at line 162 of file process.c.

Referenced by mmstat_sysfs_pagetable_show(), mmstat_sysfs_vmaps_show(), MOS_STATIC_ASSERT(), and process_wait_for_pid().

+ Here is the call graph for this function:

◆ process_attach_ref_fd()

fd_t process_attach_ref_fd ( process_t * process,
io_t * file,
fd_flags_t flags )

Definition at line 171 of file process.c.

Referenced by fd_manipulate(), io_dup(), ipc_accept(), ipc_connect(), ipc_create(), memfd_create(), MOS_STATIC_ASSERT(), MOS_STATIC_ASSERT(), process_new(), and vfs_ipc_file_read().

+ Here is the call graph for this function:

◆ process_get_fd()

io_t * process_get_fd ( process_t * process,
fd_t fd )

Definition at line 192 of file process.c.

Referenced by dentry_from_fd(), io_dup(), io_pread(), io_read(), io_readv(), io_seek(), io_tell(), io_write(), ipc_accept(), mmap_file(), MOS_STATIC_ASSERT(), MOS_STATIC_ASSERT(), and vfs_fstatat().

+ Here is the call graph for this function:

◆ process_detach_fd()

bool process_detach_fd ( process_t * process,
fd_t fd )

Definition at line 200 of file process.c.

Referenced by io_close(), io_dup2(), and process_do_execveat().

+ Here is the call graph for this function:

◆ process_wait_for_pid()

pid_t process_wait_for_pid ( pid_t pid,
u32 * exit_code,
u32 flags )

Definition at line 215 of file process.c.

Referenced by MOS_STATIC_ASSERT().

+ Here is the call graph for this function:

◆ process_exit()

void process_exit ( process_t * process,
u8 exit_code,
signal_t signal )

Definition at line 281 of file process.c.

Referenced by elf_create_process(), exit(), process_do_execveat(), signal_do_coredump(), and signal_do_terminate().

+ Here is the call graph for this function:

◆ process_dump_mmaps()

void process_dump_mmaps ( const process_t * process)

Definition at line 365 of file process.c.

Referenced by dump_process(), and invalid_page_fault().

◆ process_register_signal_handler()

bool process_register_signal_handler ( process_t * process,
signal_t sig,
const sigaction_t * sigaction )

Definition at line 380 of file process.c.

Referenced by MOS_STATIC_ASSERT().

◆ process_sysfs_process_stat()

static bool process_sysfs_process_stat ( sysfs_file_t * f)
static

Definition at line 396 of file process.c.

◆ process_sysfs_thread_stat()

static bool process_sysfs_thread_stat ( sysfs_file_t * f)
static

Definition at line 410 of file process.c.

◆ process_sysfs_vmap_stat()

static bool process_sysfs_vmap_stat ( sysfs_file_t * f)
static

Definition at line 417 of file process.c.

+ Here is the call graph for this function:

◆ SYSFS_AUTOREGISTER()

SYSFS_AUTOREGISTER ( current ,
process_sysfs_items  )

Variable Documentation

◆ process_table

◆ vmap_content_str

const char* vmap_content_str[]
static
Initial value:
= {
[VMAP_UNKNOWN] = "unknown",
[VMAP_STACK] = "stack",
[VMAP_FILE] = "file",
[VMAP_MMAP] = "mmap",
[VMAP_DMA] = "DMA",
}
@ VMAP_MMAP
Definition mm.h:25
@ VMAP_DMA
Definition mm.h:26
@ VMAP_UNKNOWN
Definition mm.h:22
@ VMAP_FILE
Definition mm.h:24
@ VMAP_STACK
Definition mm.h:23

Definition at line 36 of file process.c.

Referenced by process_dump_mmaps(), and process_sysfs_vmap_stat().

◆ vmap_type_str

const char* vmap_type_str[]
Initial value:
= {
[VMAP_TYPE_SHARED] = "shared",
[VMAP_TYPE_PRIVATE] = "private",
}
@ VMAP_TYPE_PRIVATE
Definition mm.h:31
@ VMAP_TYPE_SHARED
Definition mm.h:32

Definition at line 44 of file process.c.

Referenced by process_do_fork(), process_dump_mmaps(), and process_sysfs_vmap_stat().

◆ process_sysfs_items

sysfs_item_t process_sysfs_items[]
static
Initial value:
= {
}
static bool process_sysfs_thread_stat(sysfs_file_t *f)
Definition process.c:410
static bool process_sysfs_process_stat(sysfs_file_t *f)
Definition process.c:396
static bool process_sysfs_vmap_stat(sysfs_file_t *f)
Definition process.c:417
#define SYSFS_RO_ITEM(_name, _show_fn)
Definition sysfs.h:48

Definition at line 447 of file process.c.