- pcb->pid = alloc_pid();
- pcb->created = clock_systime();
- pcb->state = PROC_CREATED;
- pcb->pgid = pcb->pid;
+ // 注册用户栈区域
+ region_add(
+ &pcb->mm.regions, USTACK_END, USTACK_TOP, REGION_RW | REGION_RSHARED);
+
+ // 预留地址空间,具体物理页将由Page Fault Handler按需分配。
+ for (uintptr_t i = PG_ALIGN(USTACK_END); i < USTACK_TOP; i += PG_SIZE) {
+ vmm_set_mapping(PD_MOUNT_1, i, 0, PG_ALLOW_USER | PG_WRITE, VMAP_NULL);
+ }
+
+ // todo: other uspace initialization stuff
+
+ vmm_unmount_pd(PD_MOUNT_1);