1、d. What is a thread?Newer operating systems provide threads which all live in the same address space and share their file descriptors. The thread can be defined as a separate stream of execution that takes place simultaneously with and independently of everything else that might be happening.e. Why
2、are threads useful?Firstly, it spends less time to create a new thread than a process with the reason that the newly created thread only uses the current process address space, but the process not.Secondly, it is quicker to end a thread than a process. Because the threads occur in the same current p
3、rocess address, so it is quicker to switch between threads than processes.Thirdly, for the same reason mentioned above, the data which are produced by one thread can be shared by another thread immediately, also much faster than processes.Now let us try using the Timestamp program and run two thread
4、s.Right-click on Timestamp.exe and save program in drive C. This program should be executed in the Windows command console. Open the Windows command console by clicking on the Start menu on desktop, and then select Run. Type cmd in the text field and click OK. At the prompt C:, type Timestamp i 5000
5、00 p 2 Output.out; press ENTER. Note: -i specifies the number of work cycles, and -p specifies the number of threads to run.Now use the graphical interface to see the output.Right-click on Graph.exe and save the program in Drive C. Open the program. If Graph.exe does not run, refer to Appendix A. Ru
6、nning a Visual Basic File for instructions. Once Graph.exe is opened, click Select Data File, and choose the file Output.out in drive C. Note that the horizontal axis is the number of work cycles. Each thread is distinguished by a different color. The gray areas indicate that the system is not runni
7、ng the given threads. A legend for the threads is displayed at the bottom of the graph.f. Capture a screen shot of the graphical output.g. List the order in which the threads are being executed.1-1-2-2-1-1-2h. What is a context switch? How do you know a context switch occurred from the graph?When sw
8、itching the CPU to another process requires saving the state of the old process and loading the saved state for the new process, which is known as a context switch. A context usually occurs when an interrupt appears on the screen. i. What activities are performed by the processor during a context sw
9、itch?An interrupt occurs and it will do something to making notes of the address of the last instruction executed and then switch CPU to another process.j. Explain what is happening in terms of preemptive multitasking and what effect it has to the user.The processor can assign different priorities t
10、o different types of interrupts. The low-speed devices have low priority and the high-speed devices have high priority. The high priority devices can interrupt the low priority devices but the low priority devices cant interrupt the high priority devices.k. An interrupt indicates that the thread is
11、not being run and should therefore be followed by a gray gap. How does the kernel handle an interrupt?At first, the input device sends to the processor an IRQ. When the processor receives this signal of IRQ, it stops executing the application program, making notes of the address of the last instruct
12、ion executed. Then, it switches to the address of the interrupt handy, and starts executing the instructions where it finds. Try using more than two threads.At the Windows command prompt C:, type “Timestamp i 500000 p enter the number of threads to run (less than 10)” and press ENTER.l. Copy and pas
13、te the graphical output.m. List the order in which the threads are being executed.1-2-1-1-2-3-4-4-5-5-5-3-4-4-5-6-7-7-8-6-7-8-9n. Consider a set of three processes that are executed to completion. Process A takes 6 seconds, Process B takes 3 seconds, and Process C takes 5 seconds. About how long wou
14、ld it take for all the processes to be completed using preemptive multitasking, more than 14 seconds, less than 14 seconds, or exactly 14 seconds? Explain your answer.More than 14 seconds, because the context switches also cost timesNow investigate your own system.o. How much RAM (main memory) does
15、your machine have? Show proof of your answer by submitting a screenshot of the display from which you inferred your answer. 512MLaunch Microsoft Word if it is not already launched.p. How many threads does Microsoft Word launch? (Refer to 3.1.4 Lab: The Task Manager.) Show proof of your answer by sub
16、mitting a screenshot of the display from which you inferred your answer.10 q. How much memory does Microsoft Word consume? Show proof of your answer by submitting a screenshot of the display from which you inferred your answer.27368KBQuestion 2. Virtual MemoryIn this section, you will use a program
17、demonstrating how virtual memory is used. a. How does virtual memory work using a page table?When in virtual memory, every address can be translated into a physical memory address by a page table. For every page in the virtual address space, the page table gives the real address in RAM where the pag
18、e is located. b. What is the primary purpose of virtual memory?It can “add” the storage of the memory which means the program can be located flexibly. c. List three advantages of using virtual memory when executing a program.Firstly, the address space the processes assign can actually be “larger” th
19、an the physical memory available.Secondly, in a system that uses virtual memory, every program runs in its own private address space.Thirdly, using the virtual memory scheme, a small amount of RAM is required for a program to run, and the rest of the programs address space is kept on the diskExecute
20、 the Page Replacement Simulation program.Click on Paging.exe to run the application. Refer to Appendix A. Running a Visual Basic File if Paging.exe does not run. Notice the top of the program window indicates the number of request and total page faults. The table on the left represents RAM and the o
21、ne on the right represents the hard disk. The order of requests is set at default. You can also enter your own order of requests. To change the speed of the simulation, you can use the speed adjuster at the bottom-left of the program window. Each time you click on Stop or Pause, the simulation ends
22、after one complete memory access.Start the program using the default queue of requests.d. Describe what is happening for the first seven requests step-by-step for the default order of requests. There are five page faults, which means four requests is in virtual memory. At first, the computers take t
23、he request to RAM and then send it to CPU.e. When does a page fault occur, and how does the kernel handle a page fault?The address translation circuitry checks the page table but finds the page is not in RAM, so it starts a page fault (an interrupt). Then the processor stops executing the user progr
24、am and switch the control to the kernel. The kernel looks at certain status registers to make clear that where the page fault came from and know the process wants access to its virtual page, so it will give RAM and load in the page for the program. After that it will fix update the page table. After
25、 a while, control will be returned to the user program. f. Enter a sequence of eight requests in place of the default order of requests in the program that would cause four page faults.1, 2, 3, 4, 1, 2, 3, 4g. In what case is it undesirable to use virtual memory?The speed may become very low.h. Give
26、n a total paging file size of 267MB, and a RAM of size 256MB. Your applications are currently taking up 500MB of memory. How would you run an application that consumes 100 MB of memory?We can expand the virtual memory.Question 3. TroubleshootingBelow are various problem scenarios. Select the most li
27、kely cause(s) for the problem from the Causes list. CausesA. Component not plugged inB. Application software errorC. Operating system errorD. Low RAME. Slow processorF. CMOS battery failureG. Motherboard failureH. Hard disk failureI. BIOS ROM failureJ. Appropriate component driver not installed prop
28、erlyProblemsa. Program not respondingCauses: D. Low RAM or E. Slow processorb. Screen froze after successfully booting C. Operating system errorc. Programs running slowlyd. Peripheral device not working (mouse, keyboard, printer) A. Component not plugged in or J. Appropriate component driver not ins
29、talled properlye. All necessary computer system components are plugged in, but the system does not boot F. CMOS battery failure or G. Motherboard failure or I. BIOS ROM failure. f. The computer is being booted, and an error message indicates that the hard drive cannot be found. H. Hard disk failureg
30、. If low memory is a cause of the system running slowly, what can you do as a user to speed up the system?Expanding the storage of the main memory and the virtual memory, which I think is the most important.Question 4. File DirectoriesIn this question, you are given a zip file, which contains some folders and files. You will unzip the given file, manipulate the files and folders
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1