freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內容

操作系統(tǒng)課程設計---geekos操作系統(tǒng)的研究與實現(編輯修改稿)

2025-07-12 00:34 本頁面
 

【文章內容簡介】 添加至系統(tǒng)運行進程隊列,可以被調度了。 添加代碼 ================== =============== //產生一個進程(用戶態(tài)) int Spawn(const char *program, const char *mand, struct Kernel_Thread **pThread) { //TODO(Spawn a process by reading an executable from a filesystem)。 int rc。 //標記各函數的返回值,為 0 則表示成功,否則失敗 char *exeFileData = 0。//保存在內存緩沖中的用戶程序可執(zhí)行文件 ulong_t exeFileLength。//可執(zhí)行文件的長度 struct User_Context *userContext = 0。//指向 User_Coxt 的指針 struct Kernel_Thread *process = 0。//指向 Kernel_Thread *pThread 的指針 struct Exe_Format exeFormat。//調用 Parse_ELF_Executable 函數得到的可執(zhí)行文件信息 if ((rc = Read_Fully(program, (void**) amp。exeFileData, amp。exeFileLength)) != 0 ) {//調用 Read_Fully 函數將名為 program的可執(zhí)行文件全部讀入內存緩沖區(qū) Print(Failed to Read File %s!\n, program)。 goto fail。 } if((rc = Parse_ELF_Executable(exeFileData, exeFileLength, amp。exeFormat)) != 0 ) {//調用 Parse_ELF_Executable 函數分析 ELF 格式文件 Print(Failed to Parse ELF File!\n)。 goto fail。 } if((rc = Load_User_Program(exeFileData, exeFileLength, amp。exeFormat, mand, amp。userContext)) != 0) {//調用 Load_User_Program將可執(zhí)行程序的程序段和數據段裝入內存 Print(Failed to Load User Program!\n)。 goto fail。 } //在堆分配 方式下釋放內存并再次初始化 exeFileData Free(exeFileData)。 exeFileData = 0。 /* 開始用戶進程 ,調用 Start_User_Thread 函數創(chuàng)建一個進程并使其進入準備運行隊列 */ process = Start_User_Thread(userContext, false)。 if (process != 0) { //不是核心級進程 (即為用戶級進程 ) KASSERT(processrefCount == 2)。 /* 返回核心進程的指針 */ *pThread = process。 rc = processpid。//記錄當前進程的 ID } else//超出內存 project2\include\geekos\ rc = ENOMEM。 return rc。 fail: //如果新進程創(chuàng)建失敗則注銷 User_Context 對象 if (exeFileData != 0) Free(exeFileData)。//釋放內存 if (userContext != 0) Destroy_User_Context(userContext)。//銷毀進程對象 return rc。 } //切換至用戶上下文 void Switch_To_User_Context(struct Kernel_Thread* kthread, struct Interrupt_State* state) { //TODO(Switch to a new user address space, if necessary)。 static struct User_Context* s_currentUserContext。 /* last user context used */ //extern int userDebug。 struct User_Context* userContext = kthreaduserContext。//指向 User_Coxt的指針,并初始化為準備切換的進程 KASSERT(!Interrupts_Enabled())。 if (userContext == 0) { //userContext 為 0 表示此進程為核心態(tài)進程就不用切換地址空間 return。 } if (userContext != s_currentUserContext) { ulong_t esp0。 //if (userDebug) Print(A[%p]\n, kthread)。 Switch_To_Address_Space(userContext)。//為用戶態(tài)進程時則切換地址空間 esp0 = ((ulong_t) kthreadstackPage) + PAGE_SIZE。 //if (userDebug) // Print(S[%lx]\n, esp0)。 /* 新進程的核心棧 . */ Set_Kernel_Stack_Pointer(esp0)。//設置內核堆棧指針 /* New user context is active */ s_currentUserContext = userContext。 } } ================== ==================== 同 project1 =================== =================== //需在此文件各函數前增加一個函數,此函數的功能是按給定的大小創(chuàng)建一個用戶級進程上下文,具體實現如下: //函數功能 :按給定的大小創(chuàng)建一個用戶級進程上下文 static struct User_Context* Create_User_Context(ulong_t size) { struct User_Context * UserContext。 size = Round_Up_To_Page(size)。 UserContext = (struct User_Context *)Malloc(sizeof(struct User_Context))。 //為用戶態(tài)進程 if (UserContext != 0) UserContextmemory = Malloc(size)。 //為核心態(tài)進程 else goto fail。 //內存為空 if (0 == UserContextmemory) goto fail。 memset(UserContextmemory, 39。\039。, size)。 UserContextsize = size。 //以下為用戶態(tài)進程創(chuàng)建 LDT(段描述符表 ) //新建一個 LDT 描述符 UserContextldtDescriptor = Allocate_Segment_Descriptor()。 if (0 == UserContextldtDescriptor) goto fail。 //初始化段描述符 Init_LDT_Descriptor(UserContextldtDescriptor, UserContextldt, NUM_USER_LDT_ENTRIES)。 //新建一個 LDT 選擇子 UserContextldtSelector = Selector(KERNEL_PRIVILEGE, true, Get_Descriptor_Index(UserContextldtDescriptor))。 //新建一個文本段描述符 Init_Code_Segment_Descriptor( amp。UserContextldt[0], (ulong_t) UserContextmemory, size / PAGE_SIZE, USER_PRIVILEGE )。 //新建一個數據段 Init_Data_Segment_Descriptor( amp。UserContextldt[1], (ulong_t) UserContextmemory, size / PAGE_SIZE, USER_PRIVILEGE )。 //新建數據段和文本段選擇子 UserContextcsSelector = Selector(USER_PRIVILEGE, false, 0)。 UserContextdsSelector = Selector(USER_PRIVILEGE, false, 1)。 //將引用數清 0 UserContextrefCount = 0。 return UserContext。 fail: if (UserContext != 0){ if (UserContextmemory != 0){ Free(UserContextmemory)。 } Free(UserContext)。 } return 0。 } //摧毀用 戶上下文 void Destroy_User_Context(struct User_Context* userContext) { //TODO(Destroy a User_Context)。 //釋放占用的 LDT Free_Segment_Descriptor(userContextldtDescriptor)。 userContextldtDescriptor=0。 //釋放內存空間 Free(userContextmemory)。 userContextmemory=0。 //釋放 userContext 本身占用的內存
點擊復制文檔內容
畢業(yè)設計相關推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1