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

正文內(nèi)容

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

2025-07-12 00:34 本頁面
 

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