📄 新建 文本文档 (6).txt
字号:
a. What is a process?
Answer: A process is an instance of a running program.
b. What does a process include?
Answer: It includes a set of memory pages, a set of open file descriptors (if the process does any I/O), a process ID, and several other things
c. Name the possible states that a process can be in.
Answer: running, runnable, or blocked.
d. What is a thread?
Answer: A thread can be loosely defined as a separate stream of execution that takes place simultaneously with and independently of everything else that might be happening.
e. Why are threads useful?
Answer:
1. Less time to create a new thread than a process, because the newly created thread uses the current process address space.
2. Less time to terminate a thread than a process.
3. Less time to switch between two threads within the same process, partly because the newly created thread uses the current process address space.
4. Less communication overheads -- communicating between the threads of one process is simple because the threads share everything: address space, in particular. So, data produced by one thread is immediately available to all the other threads.
Now let us try using the Timestamp program and run two threads.
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 500000 –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. Running 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 running 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.
Answer: The order is 1 → 2 → 1.
h. What is a context switch? How do you know a context switch occurred from the graph?
Answer: Switching the CPU to another process requires saving the state of the old process and loading the saved state for the new process. This task is known as a context switch.
I will know a context occurred when a interrupt display on the graph.
i. What activities are performed by the processor during a context switch?
Answer: An interrupt is occurring and Switch the CPU to another process.
j. Explain what is happening in terms of preemptive multitasking and what effect it has to the user.
The processor also assigns priorities to different types of interrupts. Low-speed devices like the keyboard have low priority. High-speed devices like a SCSI disk have high priority because they need a rapid response in order to function optimally.
It avoids losing information.
k. An interrupt indicates that the thread is not being run and should therefore be followed by a gray gap. How does the kernel handle an interrupt?
One of the important jobs of the kernel is to handle interrupts. The input device sends to the processor a signal called an IRQ (interrupt request). When the processor receives this signal, it stops executing the application program (a Web page editor in our example), making note of the address of the last instruction executed. Then, it jumps to the address of the keyboard interrupt handler, and starts executing the instructions it finds there.
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 paste the graphical output.
m. List the order in which the threads are being executed.
Answer: The order is 1→2→3→4→3→4.
n. 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 would 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.
Answer: More than 14 seconds. Because the context switch also cost times.
Now investigate your own system.
o. How much RAM (main memory) does your machine have? Show proof of your answer by submitting a screenshot of the display from which you inferred your answer.
Answer: 256M
Launch 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 submitting a screenshot of the display from which you inferred your answer.
Answer: five threads.
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.
Answer: 2,308KB.
Question 2. Virtual Memory
In this section, you will use a program demonstrating how virtual memory is used.
a. How does virtual memory work using a page table?
Answer: In virtual mode, every address is "translated" into a physical memory location by means of a page table. For each page in the virtual address space, the page table gives the real address in RAM where the page is located.
b. What is the primary purpose of virtual memory?
Answer: In order to increase program flexibility.
c. List three advantages of using virtual memory when executing a program.
Answer: 1.The most important is process isolation.
2. Another advantage of virtual memory is that the address space the processes see can actually be larger than the physical memory available.
3. We need not worry about how much physical memory is on the machine. We have an entire virtual address space to use as they like, and the kernel takes care of the implementation details.
Execute 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 one 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 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.
Answer: six page faults occurred. It means five requests is in virtual memory. The computers first take it to RAM and then send it to CPU.
e. When does a page fault occur, and how does the kernel handle a page fault?
Answer: The address translation circuitry checks the page table, finds the "not in RAM" marker, and generates a page fault. This is a kind of interrupt. The processor stops executing the user program and gives control to the kernel. The kernel looks at certain status registers to figure out where the page fault came from and says, "Oh, this process wants access to its virtual page seven. I will get some RAM here and load in page seven of the program. Now I will fix update the page table, and I will let the program the instruction again." So, control is returned to the user program, and the program continues as if nothing unusual had happened.
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, 2,4,1,3,
g. In what case is it undesirable to use virtual memory?
Answer: The speed is very low.
h. Given 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?
Answer: Expand the virtual memory.
Question 3. Troubleshooting
Below are various problem scenarios. Select the most likely cause(s) for the problem from the Causes list.
Causes
A. Component not plugged in
B. Application software error
C. Operating system error
D. Low RAM
E. Slow processor
F. CMOS battery failure
G. Motherboard failure
H. Hard disk failure
I. BIOS ROM failure
J. Appropriate component driver not installed properly
a. Program not responding
causes: D. Low RAM or E. Slow processor
b. Screen froze after successfully booting
Causes: C. Operating system error
c. Programs running slowly
Causes: D. Low RAM or E. Slow processor
d. Peripheral device not working (mouse, keyboard, printer)
Causes: A. Component not plugged in or J. Appropriate component driver not installed properly.
e. All necessary computer system components are plugged in, but the system does not boot
Causes: 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.
Causes: H. Hard disk failure
g. If low memory is a cause of the system running slowly, what can you do as a user to speed up the system?
Answer: Expand the RAM. And I also can expand the virtual memory.
Question 4. File Directories
In 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, zip the resulting file structure and submit it, along with answers to the questions in this exercise.
First, download and save SSD2 File System.zip onto your Desktop. Then unzip the file.
a. What is the absolute path of the file named test.txt in SSD2 File System folder?
Answer: C:\Documents and Settings\Guest\桌面\SSD2 File System\Temp3\ test.txt
b. How many parent directories does test.txt have?
Answer: 5 parent directories.
c. Create a shortcut of test.txt and place it in the same directory. Rename the shortcut “MyTest”. Copy and paste a screenshot showing the file property of MyTest.
d. Examine the file property of test.txt. Explain why the values for Size and Size on disk are different. What is the term for the difference between the two sizes?
Answer: Shortcuts have names and live in folders just the way files do. But, a shortcut does not actually hold any data. Therefore the values for Size and Size on disk are different.
e. Opening MyTest or test.txt both result in the display of the file. Explain the difference between MyTest and test.txt.
Answer: Shortcuts have names and live in folders just the way files do. But, a shortcut does not actually hold any data. Instead, it has a shortcut property that specifies the path to the file where the data can be found. This file is called the target of the shortcut. The target can be anywhere, even on a different drive. A shortcut only refers to its target; it is not a copy of the target. So, when you open a shortcut and edit what you find there, you are actually editing the target file.
f. What are the different file extensions in folder Temp1?
Answer: .gif .html .xml
.gif is GIF image (Graphic Interchange Format)
.html is HTML (Hypertext Markup Language) document
.xml is initials for Extensible Markup Language.
g. List the most recently modified item in SSD2 File System folder.
Answer: The most recently modified item is name the shortcut of test.txt of “MyTest”
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -