To help you answer these questions, you might want to look at this math review.
The memory that a process needs in order to run is broken up into page-size units. When it is a process's turn to run, the operating system swaps the process's data from the hard disk into page frames in memory that are currently free. (If the amount of memory a process needs is not a perfect multiple of the page size, then the process simply wastes the unused space in the last page.)
User processes act as if they start at memory address 0, and continue contiguously from there. However, they might be put into any of the frames in memory. The operation system translates the "logical" addresses of the program into "physical" addresses in RAM. Thus if the process wants to access memory address 127 (a logical address), and it is put into frame number 1, its physical location is the size of a page frame plus 127.
Say we have a 32 bit machine whose page size is 256KB. Say also that one of the logical addresses is 32,892 (decimal), and is placed into frame number 7.
(1) How many pages can the system address?
(2) How many pages can be kept in a main memory of 16MB?
(3) What is the physical address for the given logical address?
Assume this system does not allow the address space for a given process to be broken up. Assume also that it does not interrupt a process while it is executing. When a process exits, its memory gets freed up.
In the case where there is not enough available memory to meet a process' request, that process will need to wait while other processes execute until enough memory is freed up. It will then be given highest priority access to that memory.
Currently four processes (A, B, C, and D) have been allocated memory in the locations shown in the diagram. The areas with slanted lines are currently free (unallocated) space. Suppose the following actions occur:
|
|
For the following questions you should describe the answers in words and pictures:
(2) Describe the contents of memory after each action using the best-fit algorithm. Be sure to note when a process must wait for another process to exit.
(3) For this example, which algorithm is best? Why?
(2) What is Thrashing? Can thrashing occur if only one user is using a machine?
(3) Consider the class Fish, as shown in Lecture 6 (slides 18 and 19). Write code to instantiate two new objects of this class. Be certain that their values are different than those shown in the lecture. Show where they would appear in memory if they were defined immediately after Charlie and Freddy. Now define a new (simple) class (say, of type Frog) and instantiate two instances of it. Place these instances directly after the Fish instances.
(1) If you are familiar with written music, analyze musical notation as a programming language. What are the control structures? What is the syntax for inserting programming comments? What music notation has syntax similar to for statements? (from Brookshear).
(2) Read up on the java bytecode specification at http://java.sun.com/docs/books/vmspec/2nd-edition/html/Compiling.doc.html (or elsewhere).
(a) Try to write some bytecode from scratch.
(b) Write a one or two page discussion of something about the bytecode approach.