Place your order now for a similar assignment and have exceptional work written by our team of experts, At affordable rates
For This or a Similar Paper Click To Order Now
Here is the input data that is refrenced in the document below :
P: 1, 2, 3, 5, 3, 6, 1, 2, 3, 5, 4, 6, 5, 2, 4, 6, 5, 2, 5, 3
P: 2, 4, 1, 3, 6, 2, 1, 3, 4, 1, 2, 2, 6, 5, 5, 6, 2, 1, 2, 1
P: 5, 2, 6, 5, 3, 1, 1, 2, 3, 5, 6, 4, 5, 2, 4, 3, 5, 2, 5, 3
P: 3, 2, 4, 6, 3, 4, 5, 3, 6, 2, 4, 4, 5, 2, 5, 6, 1, 2, 5, 2
P: 2, 5, 6, 2, 3, 4, 5, 2, 6, 5, 3, 4, 1, 2, 4, 3, 6, 1, 5, 3
P: 1, 6, 4, 2, 3, 5, 1, 6, 3, 2, 2, 4, 5, 5, 1, 1, 5, 2, 5, 1
P: 1, 4, 5, 3, 4, 2, 4, 6, 3, 5, 4, 4, 2, 2, 3, 6, 4, 1, 5, 3
P: 5, 5, 6, 4, 3, 3, 4, 5, 6, 1, 3, 4, 5, 2, 4, 2, 5, 6, 2, 4
P: 3, 4, 2, 1, 6, 3, 3, 2, 3, 5, 5, 6, 3, 1, 2, 3, 5, 6, 5, 4
P: 2, 4, 3, 6, 3, 5, 2, 6, 3, 2, 5, 1, 5, 2, 1, 6, 2, 2, 3, 3
P: 4, 3, 3, 4, 5, 1, 1, 5, 3, 6, 2, 1, 5, 6, 4, 1, 5, 4, 6, 1
P: 4, 2, 5, 2, 5, 1, 6, 4, 3, 5, 3, 4, 4, 6, 2, 3, 5, 2, 5, 3
P: 5, 3, 2, 6, 6, 2, 6, 2, 3, 5, 3, 4, 5, 1, 3, 6, 1, 3, 6, 4
P: 1, 5, 3, 5, 3, 2, 6, 1, 3, 1, 4, 4, 5, 2, 6, 3, 5, 2, 2, 5
Here is the framework provided:
import java.util.LinkedList;
class Page{
int id; //corresponding to the number of each row in the .txt file
boolean rb = true; //reference bit: true-recently used; false-ready for replacement
boolean wr = false; //write-read bit: true-been modified; false-read only. Depends on the “id” values. True: 2, 5
//false: 1, 3, 4, 6
int remaining_time = 10;
Page(int i){
id = i;
if(i == 2 || i== 5)
wr = true;
}
}
class Process{
int id;
int arrive_time; //This can be the initial arriving time also, anytime when a “page fault” occurs, it will update its new arriving time by adding the I/O cost
Page pages[] = new Page[20]; //The list of pages for execution
LinkedList ram_pages; //4 pages that are used in the RAM
int current_arm = 0; //[0, 3]
int current_quantum;
Process(int id, int[] list, int arrive_time)
{
for(int i = 0; i < 20; i++)
{
pages[i] = new Page(list[i]);
}
}
//You can copy the code we did in the class here but adapt it with clock-algorithm
void pageReplacement() {
}
/* This is the function is to mimic the process being executed in the CPU
* You can print out message here */
int execution(int current_time, int allocated_time) {
boolean pagefault = false; //This variable indicates if the needed page is available in the RAM or Not
//By default it is false
//Be aware, the following code might be execute more than once if the allocated time is more than a page time
//You need to write code here to see if the page exist in the RAM
//Here you just need to simply use a for-loop to check if page exist in "ram_pages"
if(!pagefault)
{
//This means the page is available in the RAM, just perform the allocated time and print out "start time and end time for this process" as the output
return 1; //Here should return the system current time after execution the page
}
else
{
//This means the page is not available
//Perform clock-algorithm to find a page to replace with I/O involved so return 0 and let CPU move to other process
//first
return 1; //Here should also return the system current (I put 1 just as example). If the page is not available,
//You can simply return the "current_time" without adding additional time on top of it.
}
}
}
public class OS {
//Different levels of ready queues
static LinkedList level_1;
static LinkedList level_2;
static LinkedList level_FCFS;
//Quantums
static int quantum_1 = 8; //Level_1 has 8ms of quantum
static int quantum_2 = 16; //Level_1 has 8ms of quantum
static int current_time = 0; //This is an important variable representing the current OS time. It will be updated everytime after calling “execution()” from a process
public static void main(String[] args)
{
int pages[] = {7, 2, 1, 3, 5, 20, 8, 4, 10, 6}; //The sequence of requested pages by CPU
int list_1[] = {1, 2, 3, 5, 3, 6, 1, 2, 3, 5, 4, 6, 5, 2, 4, 6, 5, 2, 5, 3};
int list_2[] = {2, 4, 1, 3, 6, 2, 1, 3, 4, 1, 2, 2, 6, 5, 5, 6, 2, 1, 2, 1};
Process p_1 = new Process(1, list_1, 0);
Process p_2 = new Process(1, list_2, 20);
//Similar as above, create 14 processes with each process’s page list initialized
//Then add process to different level queues
level_1.add(p_1);
while( !level_1.isEmpty() || !level_2.isEmpty() || !level_FCFS.isEmpty())
{
if(!level_1.isEmpty())
{
Process p = level_1.get(0);
int arrive_time = p.arrive_time;
if(current_time >= p.arrive_time) //Make sure the process arrive time is before the current_time
{
level_1.remove(0); //You can safely remove the process from the current level queue
current_time = p.execution(current_time, quantum_1); //After executing the current process, the system current time will be updated
}
}
}
}
}
Why Work with Us
Top Quality and Well-Researched Papers
We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.
Professional and Experienced Academic Writers
We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.
Free Unlimited Revisions
If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.
Prompt Delivery and 100% Money-Back-Guarantee
All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.
Original & Confidential
We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.
24/7 Customer Support
Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
Our Services
No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.
Essays
No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.
Admissions
Admission Essays & Business Writing Help
An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.
Reviews
Editing Support
Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.
Reviews
Revision Support
If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.