550W Document
550W, a high-end OS
pcb.h 文件参考
#include <asm/context.h>
#include <common/elf.h>
#include <lib/list.h>
#include <os/cpu.h>
#include <os/lock.h>
#include <os/mm.h>
#include <os/sync.h>
#include <os/time.h>
pcb.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

struct  prior
 
struct  rusage
 
struct  pcb
 

宏定义

#define NUM_MAX_PCB_NAME   20
 
#define NUM_MAX_PROCESS   16
 
#define NUM_MAX_CHILD   5
 
#define NUM_MAX_CHILD_THREADS   5
 
#define NUM_MAX_TASK   (1 + NUM_MAX_CHILD + NUM_MAX_CHILD_THREADS) * NUM_MAX_PROCESS
 
#define NUM_MAX_LOCK   16
 
#define NUM_MAX_MBOX   16
 
#define WNOHANG   0x00000001
 
#define WUNTRACED   0x00000002
 
#define WSTOPPED   WUNTRACED
 
#define WEXITED   0x00000004
 
#define WCONTINUED   0x00000008
 
#define WNOWAIT   0x01000000 /* Don't reap, just poll status. */
 
#define __WNOTHREAD   0x20000000 /* Don't wait on children of other threads in this group */
 
#define __WALL   0x40000000 /* Wait on all children, regardless of type */
 
#define __WCLONE   0x80000000 /* Wait only on non-SIGCHLD children */
 
#define PRIO_MIN   (-20)
 
#define PRIO_MAX   20
 
#define PRIO_PROCESS   0
 
#define PRIO_PGRP   1
 
#define PRIO_USER   2
 
#define CSIGNAL   0x000000ff /* signal mask to be sent at exit */
 
#define CLONE_VM   0x00000100 /* set if VM shared between processes */
 
#define CLONE_FS   0x00000200 /* set if fs info shared between processes */
 
#define CLONE_FILES   0x00000400 /* set if open files shared between processes */
 
#define CLONE_SIGHAND   0x00000800 /* set if signal handlers and blocked signals shared */
 
#define CLONE_PIDFD   0x00001000 /* set if a pidfd should be placed in parent */
 
#define CLONE_PTRACE   0x00002000 /* set if we want to let tracing continue on the child too */
 
#define CLONE_VFORK   0x00004000 /* set if the parent wants the child to wake it up on mm_release */
 
#define CLONE_PARENT   0x00008000 /* set if we want to have the same parent as the cloner */
 
#define CLONE_THREAD   0x00010000 /* Same thread group? */
 
#define CLONE_NEWNS   0x00020000 /* New mount namespace group */
 
#define CLONE_SYSVSEM   0x00040000 /* share system V SEM_UNDO semantics */
 
#define CLONE_SETTLS   0x00080000 /* create a new TLS for the child */
 
#define CLONE_PARENT_SETTID   0x00100000 /* set the TID in the parent */
 
#define CLONE_CHILD_CLEARTID   0x00200000 /* clear the TID in the child */
 
#define CLONE_DETACHED   0x00400000 /* Unused, ignored */
 
#define CLONE_UNTRACED   0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
 
#define CLONE_CHILD_SETTID   0x01000000 /* set the TID in the child */
 
#define CLONE_NEWCGROUP   0x02000000 /* New cgroup namespace */
 
#define CLONE_NEWUTS   0x04000000 /* New utsname namespace */
 
#define CLONE_NEWIPC   0x08000000 /* New ipc namespace */
 
#define CLONE_NEWUSER   0x10000000 /* New user namespace */
 
#define CLONE_NEWPID   0x20000000 /* New pid namespace */
 
#define CLONE_NEWNET   0x40000000 /* New network namespace */
 
#define CLONE_IO   0x80000000 /* Clone io context */
 

类型定义

typedef void(* void_task) ()
 
typedef struct prior prior_t
 
typedef enum task_status task_status_t
 
typedef enum task_type task_type_t
 
typedef enum enqueue_way enqueue_way_t
 
typedef enum dequeue_way dequeue_way_t
 
typedef enum unblock_way unblock_way_t
 
typedef struct rusage rusage_t
 
typedef struct pcb pcb_t
 

枚举

enum  task_status { TASK_BLOCKED , TASK_RUNNING , TASK_READY , TASK_EXITED }
 
enum  task_type { KERNEL_PROCESS , KERNEL_THREAD , USER_PROCESS , USER_THREAD }
 
enum  enqueue_way { ENQUEUE_LIST , ENQUEUE_TIMER_LIST }
 
enum  dequeue_way { DEQUEUE_LIST , DEQUEUE_LIST_STRATEGY }
 
enum  unblock_way { UNBLOCK_TO_LIST_FRONT , UNBLOCK_TO_LIST_BACK , UNBLOCK_ONLY , UNBLOCK_TO_LIST_STRATEGY }
 

函数

void k_pcb_init ()
 
void switch_to (pcb_t *prev, pcb_t *next)
 
long k_pcb_scheduler (void)
 
void k_pcb_block (list_head *, list_head *queue, enqueue_way_t way)
 
void k_pcb_unblock (list_head *, list_head *, unblock_way_t way)
 
long k_pcb_getpid (void)
 
void k_pcb_sleep (void *chan, spin_lock_t *lk)
 
void k_pcb_wakeup (void *chan)
 
long sys_sched_yield (void)
 
long sys_nanosleep (nanotime_val_t *rqtp, nanotime_val_t *rmtp)
 
long sys_spawn (const char *file_name)
 
long sys_fork (void)
 
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 sys_clone (unsigned long flags, void *stack, pid_t *parent_tid, void *tls, pid_t *child_tid)
 
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 sys_setpriority (int which, int who, int niceval)
 
long sys_getpriority (int which, int who)
 
long sys_getpid (void)
 [SYSCALL] getpid: get current task process id 更多...
 
long sys_getppid (void)
 [SYSCALL] getppid: get parent of current task pid 更多...
 
long sys_sched_setaffinity (pid_t pid, unsigned int len, const uint8_t *user_mask_ptr)
 
long sys_sched_getaffinity (pid_t pid, unsigned int len, uint8_t *user_mask_ptr)
 

变量

pcb_mbox_t pcb_mbox [NUM_MAX_PROCESS]
 
pcb_t *volatile current_running0
 
pcb_t *volatile current_running1
 
pcb_t *volatile *volatile current_running
 
list_head ready_queue
 
list_head block_queue
 
pcb_t pcb [NUM_MAX_TASK]
 
const ptr_t pid0_stack
 
const ptr_t pid0_stack2
 
pcb_t pid0_pcb
 
pcb_t pid0_pcb2
 
pid_t freepid [NUM_MAX_TASK]
 

宏定义说明

◆ __WALL

#define __WALL   0x40000000 /* Wait on all children, regardless of type */

◆ __WCLONE

#define __WCLONE   0x80000000 /* Wait only on non-SIGCHLD children */

◆ __WNOTHREAD

#define __WNOTHREAD   0x20000000 /* Don't wait on children of other threads in this group */

◆ CLONE_CHILD_CLEARTID

#define CLONE_CHILD_CLEARTID   0x00200000 /* clear the TID in the child */

◆ CLONE_CHILD_SETTID

#define CLONE_CHILD_SETTID   0x01000000 /* set the TID in the child */

◆ CLONE_DETACHED

#define CLONE_DETACHED   0x00400000 /* Unused, ignored */

◆ CLONE_FILES

#define CLONE_FILES   0x00000400 /* set if open files shared between processes */

◆ CLONE_FS

#define CLONE_FS   0x00000200 /* set if fs info shared between processes */

◆ CLONE_IO

#define CLONE_IO   0x80000000 /* Clone io context */

◆ CLONE_NEWCGROUP

#define CLONE_NEWCGROUP   0x02000000 /* New cgroup namespace */

◆ CLONE_NEWIPC

#define CLONE_NEWIPC   0x08000000 /* New ipc namespace */

◆ CLONE_NEWNET

#define CLONE_NEWNET   0x40000000 /* New network namespace */

◆ CLONE_NEWNS

#define CLONE_NEWNS   0x00020000 /* New mount namespace group */

◆ CLONE_NEWPID

#define CLONE_NEWPID   0x20000000 /* New pid namespace */

◆ CLONE_NEWUSER

#define CLONE_NEWUSER   0x10000000 /* New user namespace */

◆ CLONE_NEWUTS

#define CLONE_NEWUTS   0x04000000 /* New utsname namespace */

◆ CLONE_PARENT

#define CLONE_PARENT   0x00008000 /* set if we want to have the same parent as the cloner */

◆ CLONE_PARENT_SETTID

#define CLONE_PARENT_SETTID   0x00100000 /* set the TID in the parent */

◆ CLONE_PIDFD

#define CLONE_PIDFD   0x00001000 /* set if a pidfd should be placed in parent */

◆ CLONE_PTRACE

#define CLONE_PTRACE   0x00002000 /* set if we want to let tracing continue on the child too */

◆ CLONE_SETTLS

#define CLONE_SETTLS   0x00080000 /* create a new TLS for the child */

◆ CLONE_SIGHAND

#define CLONE_SIGHAND   0x00000800 /* set if signal handlers and blocked signals shared */

◆ CLONE_SYSVSEM

#define CLONE_SYSVSEM   0x00040000 /* share system V SEM_UNDO semantics */

◆ CLONE_THREAD

#define CLONE_THREAD   0x00010000 /* Same thread group? */

◆ CLONE_UNTRACED

#define CLONE_UNTRACED   0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */

◆ CLONE_VFORK

#define CLONE_VFORK   0x00004000 /* set if the parent wants the child to wake it up on mm_release */

◆ CLONE_VM

#define CLONE_VM   0x00000100 /* set if VM shared between processes */

◆ CSIGNAL

#define CSIGNAL   0x000000ff /* signal mask to be sent at exit */

◆ NUM_MAX_CHILD

#define NUM_MAX_CHILD   5

◆ NUM_MAX_CHILD_THREADS

#define NUM_MAX_CHILD_THREADS   5

◆ NUM_MAX_LOCK

#define NUM_MAX_LOCK   16

◆ NUM_MAX_MBOX

#define NUM_MAX_MBOX   16

◆ NUM_MAX_PCB_NAME

#define NUM_MAX_PCB_NAME   20

◆ NUM_MAX_PROCESS

#define NUM_MAX_PROCESS   16

◆ NUM_MAX_TASK

#define NUM_MAX_TASK   (1 + NUM_MAX_CHILD + NUM_MAX_CHILD_THREADS) * NUM_MAX_PROCESS

◆ PRIO_MAX

#define PRIO_MAX   20

◆ PRIO_MIN

#define PRIO_MIN   (-20)

◆ PRIO_PGRP

#define PRIO_PGRP   1

◆ PRIO_PROCESS

#define PRIO_PROCESS   0

◆ PRIO_USER

#define PRIO_USER   2

◆ WCONTINUED

#define WCONTINUED   0x00000008

◆ WEXITED

#define WEXITED   0x00000004

◆ WNOHANG

#define WNOHANG   0x00000001

◆ WNOWAIT

#define WNOWAIT   0x01000000 /* Don't reap, just poll status. */

◆ WSTOPPED

#define WSTOPPED   WUNTRACED

◆ WUNTRACED

#define WUNTRACED   0x00000002

类型定义说明

◆ dequeue_way_t

typedef enum dequeue_way dequeue_way_t

◆ enqueue_way_t

typedef enum enqueue_way enqueue_way_t

◆ pcb_t

typedef struct pcb pcb_t

◆ prior_t

typedef struct prior prior_t

◆ rusage_t

typedef struct rusage rusage_t

◆ task_status_t

typedef enum task_status task_status_t

◆ task_type_t

typedef enum task_type task_type_t

◆ unblock_way_t

typedef enum unblock_way unblock_way_t

◆ void_task

typedef void(* void_task) ()

枚举类型说明

◆ dequeue_way

枚举值
DEQUEUE_LIST 
DEQUEUE_LIST_STRATEGY 

◆ enqueue_way

枚举值
ENQUEUE_LIST 
ENQUEUE_TIMER_LIST 

◆ task_status

枚举值
TASK_BLOCKED 
TASK_RUNNING 
TASK_READY 
TASK_EXITED 

◆ task_type

enum task_type
枚举值
KERNEL_PROCESS 
KERNEL_THREAD 
USER_PROCESS 
USER_THREAD 

◆ unblock_way

枚举值
UNBLOCK_TO_LIST_FRONT 
UNBLOCK_TO_LIST_BACK 
UNBLOCK_ONLY 
UNBLOCK_TO_LIST_STRATEGY 

函数说明

◆ k_pcb_block()

void k_pcb_block ( list_head 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)

◆ switch_to()

void switch_to ( pcb_t prev,
pcb_t next 
)

◆ 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 uint8_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 
)

变量说明

◆ block_queue

list_head block_queue
extern

◆ current_running

pcb_t* volatile* volatile current_running
extern

◆ current_running0

pcb_t* volatile current_running0
extern

◆ current_running1

pcb_t* volatile current_running1
extern

◆ freepid

pid_t freepid[NUM_MAX_TASK]
extern

◆ pcb

◆ pcb_mbox

◆ pid0_pcb

pcb_t pid0_pcb
extern

◆ pid0_pcb2

pcb_t pid0_pcb2
extern

◆ pid0_stack

const ptr_t pid0_stack
extern

◆ pid0_stack2

const ptr_t pid0_stack2
extern

◆ ready_queue

list_head ready_queue
extern