550W Document
550W, a high-end OS
pcb.c 文件参考
#include <asm/atomic.h>
#include <asm/pgtable.h>
#include <asm/stack.h>
#include <common/elf.h>
#include <drivers/screen/screen.h>
#include <fs/fs.h>
#include <lib/math.h>
#include <lib/stdio.h>
#include <lib/string.h>
#include <os/irq.h>
#include <os/pcb.h>
#include <os/smp.h>
#include <user/user_programs.h>
pcb.c 的引用(Include)关系图:

函数

 LIST_HEAD (ready_queue)
 
 LIST_HEAD (block_queue)
 
pid_t nextpid ()
 
void init_pcb_i (char *name, int pcb_i, task_type_t type, int pid, int fpid, int tid, int father_pid, uint8_t core_mask)
 
uintptr_t init_user_stack (ptr_t *user_stack_kva, ptr_t *user_stack, int argc, const char *argv[], int envpc, const char *envp[], const char *file_name)
 
void k_pcb_init ()
 
long sys_setpriority (int which, int who, int niceval)
 
long sys_getpriority (int which, int who)
 
uint64_t cal_priority (uint64_t cur_time, uint64_t idle_time, long priority)
 
pcb_tcheck_first_ready_task ()
 
pcb_tchoose_sched_task (list_head *queue)
 
void enqueue (list_head *new, list_head *head, enqueue_way_t way)
 
pcb_tdequeue (list_head *queue, dequeue_way_t target)
 
long sys_nanosleep (nanotime_val_t *rqtp, nanotime_val_t *rmtp)
 
void check_sleeping ()
 
long k_pcb_scheduler (void)
 
long sys_sched_yield (void)
 
void k_pcb_block (list_node_t *pcb_node, list_head *queue, enqueue_way_t way)
 
void k_pcb_unblock (list_head *from_queue, list_head *to_queue, unblock_way_t way)
 
long sys_sched_setaffinity (pid_t pid, unsigned int len, const byte_size_t *user_mask_ptr)
 
long sys_sched_getaffinity (pid_t pid, unsigned int len, uint8_t *user_mask_ptr)
 
long spawn (const char *file_name)
 
long sys_spawn (const char *file_name)
 
long sys_fork ()
 
int kill (pid_t pid, int exit_status)
 
long sys_kill (pid_t pid)
 
long sys_exit (int error_code)
 
long sys_wait4 (pid_t pid, int *stat_addr, int options, rusage_t *ru)
 
long sys_process_show ()
 
long exec (int target_pid, int father_pid, const char *file_name, const char *argv[], const char *envp[])
 
long sys_exec (const char *file_name, const char *argv[], const char *envp[])
 
long sys_execve (const char *file_name, const char *argv[], const char *envp[])
 
long clone (unsigned long flags, void *stack, pid_t *parent_tid, void *tls, pid_t *child_tid)
 
long sys_clone (unsigned long flags, void *stack, pid_t *parent_tid, void *tls, pid_t *child_tid)
 
long k_pcb_getpid (void)
 
long sys_getpid ()
 [SYSCALL] getpid: get current task process id 更多...
 
long sys_getppid ()
 [SYSCALL] getppid: get parent of current task pid 更多...
 
void k_pcb_sleep (void *chan, spin_lock_t *lk)
 
void k_pcb_wakeup (void *chan)
 

变量

pcb_t *volatile current_running0
 
pcb_t *volatile current_running1
 
pcb_t *volatile *volatile current_running
 
pcb_t pcb [NUM_MAX_TASK]
 
const ptr_t pid0_stack = INIT_KERNEL_STACK + PAGE_SIZE * 3 - 112 - 288
 
const ptr_t pid0_stack2 = INIT_KERNEL_STACK + PAGE_SIZE * 5 - 112 - 288
 
pcb_t pid0_pcb = {.pid = -1, .kernel_sp = (ptr_t)pid0_stack, .user_sp = (ptr_t)(INIT_KERNEL_STACK + PAGE_SIZE * 2), .core_mask[0] = 0x3, .status = TASK_EXITED}
 
pcb_t pid0_pcb2 = {.pid = -1, .kernel_sp = (ptr_t)pid0_stack2, .user_sp = (ptr_t)(INIT_KERNEL_STACK + PAGE_SIZE * 4), .core_mask[0] = 0x3, .status = TASK_EXITED}
 
pid_t freepid [NUM_MAX_TASK]
 

函数说明

◆ cal_priority()

uint64_t cal_priority ( uint64_t  cur_time,
uint64_t  idle_time,
long  priority 
)

◆ check_first_ready_task()

pcb_t* check_first_ready_task ( )

◆ check_sleeping()

void check_sleeping ( )

◆ choose_sched_task()

pcb_t* choose_sched_task ( list_head queue)

◆ clone()

long clone ( unsigned long  flags,
void *  stack,
pid_t parent_tid,
void *  tls,
pid_t child_tid 
)

◆ dequeue()

pcb_t* dequeue ( list_head queue,
dequeue_way_t  target 
)

◆ enqueue()

void enqueue ( list_head new,
list_head head,
enqueue_way_t  way 
)

◆ exec()

long exec ( int  target_pid,
int  father_pid,
const char *  file_name,
const char *  argv[],
const char *  envp[] 
)

◆ init_pcb_i()

void init_pcb_i ( char *  name,
int  pcb_i,
task_type_t  type,
int  pid,
int  fpid,
int  tid,
int  father_pid,
uint8_t  core_mask 
)

◆ init_user_stack()

uintptr_t init_user_stack ( ptr_t user_stack_kva,
ptr_t user_stack,
int  argc,
const char *  argv[],
int  envpc,
const char *  envp[],
const char *  file_name 
)

◆ k_pcb_block()

void k_pcb_block ( list_node_t pcb_node,
list_head queue,
enqueue_way_t  way 
)

◆ k_pcb_getpid()

long k_pcb_getpid ( void  )

◆ k_pcb_init()

void k_pcb_init ( )

◆ k_pcb_scheduler()

long k_pcb_scheduler ( void  )

◆ k_pcb_sleep()

void k_pcb_sleep ( void *  chan,
spin_lock_t lk 
)

◆ k_pcb_unblock()

void k_pcb_unblock ( list_head from_queue,
list_head to_queue,
unblock_way_t  way 
)

◆ k_pcb_wakeup()

void k_pcb_wakeup ( void *  chan)

◆ kill()

int kill ( pid_t  pid,
int  exit_status 
)

◆ LIST_HEAD() [1/2]

LIST_HEAD ( block_queue  )

◆ LIST_HEAD() [2/2]

LIST_HEAD ( ready_queue  )

◆ nextpid()

pid_t nextpid ( )

◆ spawn()

long spawn ( const char *  file_name)

◆ sys_clone()

long sys_clone ( unsigned long  flags,
void *  stack,
pid_t parent_tid,
void *  tls,
pid_t child_tid 
)

◆ sys_exec()

long sys_exec ( const char *  file_name,
const char *  argv[],
const char *  envp[] 
)

◆ sys_execve()

long sys_execve ( const char *  file_name,
const char *  argv[],
const char *  envp[] 
)

◆ sys_exit()

long sys_exit ( int  error_code)

◆ sys_fork()

long sys_fork ( void  )

◆ sys_getpid()

long sys_getpid ( void  )

[SYSCALL] getpid: get current task process id

返回
long

◆ sys_getppid()

long sys_getppid ( void  )

[SYSCALL] getppid: get parent of current task pid

返回
long

◆ sys_getpriority()

long sys_getpriority ( int  which,
int  who 
)

◆ sys_kill()

long sys_kill ( pid_t  pid)

◆ sys_nanosleep()

long sys_nanosleep ( nanotime_val_t rqtp,
nanotime_val_t rmtp 
)

◆ sys_process_show()

long sys_process_show ( )

◆ sys_sched_getaffinity()

long sys_sched_getaffinity ( pid_t  pid,
unsigned int  len,
uint8_t *  user_mask_ptr 
)

◆ sys_sched_setaffinity()

long sys_sched_setaffinity ( pid_t  pid,
unsigned int  len,
const byte_size_t user_mask_ptr 
)

◆ sys_sched_yield()

long sys_sched_yield ( void  )

◆ sys_setpriority()

long sys_setpriority ( int  which,
int  who,
int  niceval 
)

◆ sys_spawn()

long sys_spawn ( const char *  file_name)

◆ sys_wait4()

long sys_wait4 ( pid_t  pid,
int *  stat_addr,
int  options,
rusage_t ru 
)

变量说明

◆ current_running

pcb_t* volatile* volatile current_running

◆ current_running0

pcb_t* volatile current_running0

◆ current_running1

pcb_t* volatile current_running1

◆ freepid

pid_t freepid[NUM_MAX_TASK]

◆ pcb

◆ pid0_pcb

pcb_t pid0_pcb = {.pid = -1, .kernel_sp = (ptr_t)pid0_stack, .user_sp = (ptr_t)(INIT_KERNEL_STACK + PAGE_SIZE * 2), .core_mask[0] = 0x3, .status = TASK_EXITED}

◆ pid0_pcb2

pcb_t pid0_pcb2 = {.pid = -1, .kernel_sp = (ptr_t)pid0_stack2, .user_sp = (ptr_t)(INIT_KERNEL_STACK + PAGE_SIZE * 4), .core_mask[0] = 0x3, .status = TASK_EXITED}

◆ pid0_stack

const ptr_t pid0_stack = INIT_KERNEL_STACK + PAGE_SIZE * 3 - 112 - 288

◆ pid0_stack2

const ptr_t pid0_stack2 = INIT_KERNEL_STACK + PAGE_SIZE * 5 - 112 - 288