操作系统课设实验报告一

时间:2021-05-06 15:44:37
【文件属性】:
文件名称:操作系统课设实验报告一
文件大小:1.53MB
文件格式:DOC
更新时间:2021-05-06 15:44:37
Nachos gdb SWITCH() ThreadRoot() The main.cc program of Nachos in ../threads/ calls function ThreadTest() as follows: void ThreadTest() { DEBUG(’t’, "Entering SimpleTest"); Thread *t = new Thread("forked thread"); t->Fork(SimpleThread, 1); SimpleThread(0); } The SimpleThread() function used above is as follows: void SimpleThread(_int which) { int num; for (num = 0; num < 5; num++) { printf("*** thread %d looped %d times\n", (int) which, num); currentThread->Yield(); } } Your tasks of this lab session is to 1. trace the execution of Nachos and observe the executions of (a) context switch function SWITCH() (b) function ThreadRoot() using gdb and 2. answer the following questions: (a) What are the addresses of the following functions in your Nachos: i. InterruptEnable() ii. SimpleThread() iii. ThreadFinish() iv. ThreadRoot() and describe how did you find them. (b) What are the addresses of the thread objects for i. the main thread of the Nachos ii. the forked thread created by the main thread and describe how did you find them. (c) When the main thread executes SWITCH() function for the first time, to what address the CPU returns when it executes the last instruction ret of SWITCH()? What location in the program that address is referred to? (d) When the forked thread executes SWITCH() function for the first time, to what address the CPU returns when it executes the last instruction ret of SWITCH()? What location in the program that address is referred to?

网友评论

相关文章