zoukankan      html  css  js  c++  java
  • [OS][MIT 6.828] Lab 3: User Environments(i.e., Processes)

    Part A: User Environments and Exception Handling

    1. User Environments

    struct used to represent an environment
    struct Env {
    	struct Trapframe env_tf;	// Saved registers
    	struct Env *env_link;		// Next free Env
    	envid_t env_id;			// Unique environment identifier
    	envid_t env_parent_id;		// env_id of this env's parent
    	enum EnvType env_type;		// Indicates special system environments
    	unsigned env_status;		// Status of the environment
    	uint32_t env_runs;		// Number of times environment has run
    
    	// Address space
    	pde_t *env_pgdir;		// Kernel virtual address of page dir
    };
    
    three main global variables pertaining to environments:
    struct Env *envs = NULL;		// All environments
    struct Env *curenv = NULL;		// The current env
    static struct Env *env_free_list;	// Free environment list
    
    functions used for running environments
    int envid2env(envid_t envid, struct Env **env_store, bool checkperm) // Converts an envid to an env pointer.
    int env_alloc(struct Env **newenv_store, envid_t parent_id)  // alloc an Env from array envs, init variables in Env.
          static int env_setup_vm(struct Env *e) // Initialize the KERNEL virtual memory layout for environment e. ONLY used in env_alloc()
    static void region_alloc(struct Env *e, void *va, size_t len) // Allocate len bytes of physical memory for environment e, and map it at virtual address va.
    void env_create(uint8_t *binary, enum EnvType type) // create env ONLY during kernel initialization, later we should use fork
          static void load_icode(struct Env *e, uint8_t *binary) // only used in env_create()
    void env_free(struct Env *e) // Frees env e and all memory it uses.
    void env_destroy(struct Env *e)
    void env_pop_tf(struct Trapframe *tf)
    void env_run(struct Env *e)
    
    summary of the creation of an environment
    1. Allocate an Env from array envs. Implemented by env_alloc().
    2. Initialize env_pgdir field of Env, actually, Initialize the virtual memory layout above UTOP including. Implemented by env_setup_vm().
    3. Initialize the rest fields of Env, except env_tf.tf_eip. Implemented by env_alloc().
    4. Load executable image into memory, initialize env_tf.tf_eip field. Implememted by load_icode().
    5. Allocate 1 page memory for the initial stack and map it at USTACKTOP - PGSIZE. Implemented by region_alloc().

    2. Exception Handling

    summary of the function chain when handle a trap
    1. t_*() :Defined by macros TRAPHANDLER and TRAPHANDLER_NOEC in trapentry.S.
    2. _alltraps() :All fiels of trap frame are saved up to here.
    3. trap()
    4. trap_dispatch()
    5. specific funtion corresponding to each trap

    Part B: Page Faults, Breakpoints Exceptions, and System Calls

    NULL

  • 相关阅读:
    Sql 复习(1)
    记录一次git issue
    JWT自校验框架
    分布式事务分布式锁的常用解决方式
    SpringBoot开发文档
    SpringCloud的使用以及五大核心组件
    SpringMVC
    关于开发中使用AOP的坑
    SpringCloud使用feign远程调用服务注入映射接口失败问题
    springBoot使用Restful跳转路径回显异常问题
  • 原文地址:https://www.cnblogs.com/-zyq/p/13975183.html
Copyright © 2011-2022 走看看