For Project 1: The outline can be informal but should explain the flow/algorithm of your program and any major methods that you will write. You can use any combination of diagrams, paragraphs explaining your plan, or pseudo-code (which can be comments and method headers in a .java file).
For Projects 2 - 4: The outline must be done in pseudo-code. The goal of this is two-fold: 1) to practice writing pseudo-code, and 2) to think about how your program will be organized before you begin coding. Here is a good description of what pseudo-code is and how to write it.
If the project you turn in differs significantly from your plan, you must include a paragraph explaining why you made the change (i.e. what was wrong with your plan and how your new design fixes it) If your plan only covers some of the parts (see Grading section) and you later decide you want to submit more parts, you should include an outline for the missing parts with your final project submission.
You can use the following Java classes to create and monitor the child process:
The method Runtime.exec() will create a child process that executes the specified command.
The method waitFor() in class Process can be used to wait until a (child) process has finished.
Assume that the user gives the full path name for all commands/executables. For example, the user would give "/bin/ls" rather than "ls".
For this part, you will add error checking of input to your shell. Your shell should be able to deal with the user hitting enter but not writing any commands, extra white space, etc.
As well, you should write a second Java program/class called CommandLineTest. This class should have its own main() method, and we will run it at the command line (your prompt) using the build-in 'java' command.
This program takes in 1 mandatory command line argument and two optional command line arguments. The optional command line arguments should be able to be entered in any order. The syntax is:
java CommandLineTest <optional arguments> num
where num is an integer greater than or equal to 0 and the optional arguments are:-s and -e.
This program should print out "middle" num times. If the -s option is included, it should print out "Starting..." at the start of the program, and if the -e option is included it should print out "Ending..." at the end of the program.
For example, prompt>java CommandLineTest 5 should print out:
middle
middle
middle
middle
middle
prompt>java CommandLineTest -e -s 3 OR prompt>java CommandLineTest -s -e 3 should print out:
Starting...
middle
middle
middle
Ending...
prompt>java CommandLineTest -e 0 should print out:
Ending...
Do NOT use a pre-existing command line argument parser. You should write your own. It only needs to be able to handle this one program
CMP 697 students: Your -e option should also be able to take in an optional parameter (i.e. -e 3) that specifies the number of times to print "Ending...". If no number is given, print "Ending..." once. All of the above example still hold. Here is another example with the optional parameter:
prompt>java CommandLineTest -s -e 2 0 should print out:
Starting...
Ending...
Ending...
Hint 1: Consider using switch.
Hint 2: You can run a program with arguments in Eclipse, by going to menu item Run->Run Configurations, and clicking on the Arguments tab. Enter the command line arguments in the white box. Eclipse will run your program as if it has been run at the command line with these arguments.
In Parts 1 and 2, the shell was used interactively by the user. That is, the user would enter a command, the shell would parse and execute it, and then the user could enter another command, etc.
For Part 3, you will expand your shell program so that it can also run in batch mode. In batch mode, the user will specify a file containing a list of commands, one per line. The shell will then read in the commands, and execute them one at a time, in the order they appear in the file. In other words, these commands are not executed interactively, but as a group (or batch!). To enter batch mode, the user will type prompt>run <batch file name>. Your shell should then execute all commands in the file <batch file name>. Then it should become an interactive shell again.
For this project, you will write a program to simulate how page tables and pages work in memory. The main method will be inside a class called OS, which represents an operating system. This class will contain a page table and an array of Page objects, which represent pages in memory. We will assume there is only one process/page table/set of pages for this project.
For this part, you will start writing the two classes: OS, which represents an operating system; and Page, which represent a page in memory. You may change the method parameter names below, but not the names of the methods themselves (since they are used for testing in Mimir).
The class Page should contain:
The class OS should contain:
Modify your code so that it can accept any number of pages and bytes of data per page, with the constraint that the corresponding virtual address size will be less than or equal to 32 bits (= size of an int in Java). The number of pages and number of bytes per page will always be given at the top of the data file. Two sample data files (also used in the test cases): proj2_data3.txt and proj2_data4.txt.
For this part, you will create a (simulated) Translation Lookaside Buffer (TLB) that uses the random replacement policy. There are no Mimir test cases, so you have more freedom in how you implement this part.
You can simulate the TLB however you would like, but you should be able to specify the number of entries it holds. One way is to create a 2D array as an instance variable of your OS class, where the size of the array is (number of entries in TLB) x 2. If your array name is tlb, then tlb[i][0] would be the virtual page number at entry i and tlb[i][1] would be the corresponding physical page number. Or, if you are planning to do the next part, you could make a new class to represent an entry in the TLB, and use an array (or some other data structure) of this class as the TLB.
Once all of the TLB entries are filled for the first time, the entry to be replaced should be chosen at random.
To simulate it taking more time to find the physical address if the virtual address is not in the TLB, add a delay for this case using TimeUnit.MILLISECONDS.sleep(...) (or a similar method).
There should be an easy way to specify the number of entries in the TLB and the delay used if the physical address is not in the TLB. For example, you could make a second constructor that also takes in these parameters.
Now you will use your code to perform some analysis. Either choose i) 2 different delay times and 5 different TLB size, or ii) 5 different delay times and 2 different TLB sizes. Run your code on the following four files, which contain lists of virtual memory addresses to access (i.e. the memory calls a process might make). For each delay time and TLB size, compute the total time it took your program to calculate the corresponding physical addresses for each file. Display this information in a graph or a chart. What do you notice? Why do you think that is the case?
Lists of virtual memory addresses to come! Note that you will also have to write code to read in these files and time the computations. Still to come. This section will be updated first on Mimir (and posted as an annoucement on Blackboard).
Add an option to choose the entry to replace in your TLB using a Least-Recently Used (LRU) policy instead of randomly selecting the entry.
Repeat your computations and analysis from the previous part using the LRU replacement policy. When is the LRU policy better the random replacement? Are there any cases in which it is worse?
A license should have been applied to your account so that you can use Mimir for free. If it is still saying you are in the 2 week free trial period, please contact me.