EssayGhost Assignment代写,Essay代写,网课代修,Quiz代考

EssayGhost-Essay代写,作业代写,网课代修代上,cs代写代考

一站式网课代修,论文代写

高质量的Assignment代写、Paper代写、Report代写服务

EG1hao
网课代修代上,cs代写代考
C++代做
您的位置: 主页 > 编程案例 > C++代做 >
代做C++/C:linux OS代写 C++/C语言lab1cs代写 - C++代做
发布时间:2021-07-25 22:40:37浏览次数:
Submit your Lab 1 document (doc or pdf) including the disclosure form and answers to the Turnitin link on the blackboard (under Assignments).Due: Sep. 14 (Friday)Late submission: you have total 72 hours throughout the semester.  linux OS代写Download Nachos.tar from the blackboard and unpack it. Answer all of the following questions by examining the Nachos code (all sub-directories of code directory). (1) (5pts) What are the possible NachosProcess (called Thread) states and where are they defined (filename line number)?ANS: JUST_CREATED, RUNNING, READY, BLOCKEDIn file code/threads/thread.h, line 63 (2) (5 pts) In threadtest.cc, how many lines are printed when you change:for(int num = 0; num num++)tofor(int num = 0; num which; num++)Why is that?ANS:1 line. The thread t starts with parameter 1, which prints 1 line. And the call SimpleThread(0) doesn’t do anything. (3) (10 pts) Draw the call graph of creating a new NachoProcess with SimpleThread function.ANS:The first call to new a Thread object simply sets its initial value and makes no further function call. What matters is the latter Fork: These codes are in code/threads/thread.cc – Thread::Fork(4) (25 pts) Using flags will help you design and test your operating system (later in other labs and programming assignments).To use a flag: ./nachos -flagExamine source code for all the predefined flags and discuss briefly how Nachos operates and what information is displayed if it exists for each flag and its parameter(s).ANS:Those flags are described in code/threads/main.cc.l -d is the debug flag, and its flag parameters is defined in code/lib/debug.h. For example, “-d sf” means debug information of semaphores and file system is printed during the OS operation. To print debug information for, e.g. file system, “DEBUG(‘f’, “message”);” would print the message if ‘f’ is included in flag parameters.l -z prints copyright string in copyright.h.l -x would load a user program from disk and executes it.l -K calls the ThreadTest() function that test thread functions.l -C calls the ConsoleTest() that tests the console’s IO.l -N tests network communication between host 0 and host 1.The following flags requires nachos file system to be enabled, using the compile flag.l -cp copies file from UNIX file system to nachos file system.l -p prints file content of the specific file.l -r removes file from file system.l -l is similar to ls in bash.l -D prints entire content of the file system, including bitmap’s header, directory’s header, and their content.(5) (10pts) What system calls are currently implemented in Nachos? Explain what it does in detail and find a corresponding UNIX system call if exists.ANS:SysHalt and SysAdd, called in userprog/exception.cc and implemented in ksyscall.h.SysHalt calls kernel- interrupt- Halt() directly, which would shutdown the system. Similar to UNIX system call halt.SysAdd sums parameters and return the result.(6) (15pts) What would happen when you execute the halt program (code/test/halt.c) ./nachos -x ~/test/halt? Explain why it happens. Draw the call graph from a user program (halt) instruction to running a system call implementation.ANS: First the program file “halt” is loaded into an address space, then the program in “halt” is executed(the main function in halt.c is called). In the main function of halt.c, Halt() is called, which is declared in syscall.h. Its implementation is written in start.S in code/test and is written in assembly.It first put the system call number to register 2, then call syscall, which would generate an interrupt and is captured and handled in ExceptionHandler() in userprog/exception.cc. It first check the exception type, and finds out that it’s a system call, and use the value in register 2 as the call number, then call SysHalt() defined in userprog/ksyscall.h.(7) (10 pts) What would happen when you execute the shell program (code/test/shell.c)? Explain why it happens.ANS:“Unexpected system call” and system exits. Though Write interface is defined in syscall.h and start.S, the system call number it uses and captured by ExceptionHandler does not have an corresponding code, i.e. there is no case SC_Write in ExceptionHandler.(8) (5pts) Which emulated MIPS CPU register contains the system call code?ANS:Register 2. See code/userprog/exception.cc – line 54. (9) (15 pts) Explain the difference between the threads created in ThreadTest() and the thread created for executing halt (or shell).ANS:The thread created in ThreadTest() is created by Fork, which makes it a whole new ready-to-run thread in the scheduler’s ready list. That thread can be executed is because the scheduler schedules it up.The thread created for executing halt is actually the same thread threads/main.cc’s main() function uses. The halt file is loaded into a new addrspace, and the addrspace of current thread is replaced into the new one, i.e. the code in the main()’s thread is replaced into the code in file halt.最先出自315代写 cs代写 作业代写 代写c合作:315代写

所有的编程代写范围:essayghost为美国、加拿大、英国、澳洲的留学生提供C语言代写、代写C语言、C语言代做、代做C语言、数据库代写、代写数据库、数据库代做、代做数据库、Web作业代写、代写Web作业、Web作业代做、代做Web作业、Java代写、代写Java、Java代做、代做Java、Python代写、代写Python、Python代做、代做Python、C/C++代写、代写C/C++、C/C++代做、代做C/C++、数据结构代写、代写数据结构、数据结构代做、代做数据结构等留学生编程作业代写服务。