Question
Rate monotonic (RM) and earliest deadline first (EDF) are two popular scheduling algorithms for real-time systems. Describe these algorithms, illustrating your answer by showing how
Rate monotonic (RM) and earliest deadline first (EDF) are two popular scheduling algorithms for real-time systems. Describe these algorithms, illustrating your answer by showing how each of them would schedule the following task set. Task Requires Exactly Every A 2ms 10ms B 1ms 4ms C 1ms 5ms You may assume that context switches are instantaneous. Which of these is harder to implement using the standard Unix access control mechanisms, and why? [10 marks] Sketch an implementation of the easier policy using Unix mechanisms. [5 marks] Describe at least two alternative mechanisms that might be used to implement the other policy. [5 marks] 5 Data Structures and Algorithms Describe an efficient algorithm based on Quicksort that will find the element of a set that would be at position k if the elements were sorted. [6 marks] Describe another algorithm that will find the same element, but with a guaranteed worst case time of O(n).
(a) What is microcode and how does it differ from assembler? [6 marks] (b) In assembler, branch instructions are used to change the flow of control. How can flow control be determined in a microcode environment? [4 marks] (c) With the aid of a diagram, explain what a feedback path (sometimes called a bypass) is and how it is used to improve the throughput of a pipeline. [6 marks] (d) What is a branch delay slot? [4 marks] 2 CST.2002.6.3 3 Digital Communication I Define a resource in a digital communication system as anything whose use by one instance of communication prevents simultaneous use by another. Channel capacity is one example. (a) Give two more examples of resource in digital communication systems. [4 marks] (b) For the three resources, indicate how the amount of total resource can be increased. [6 marks] (c) How are allocations of each of these resources to instances of communication performed? [10 marks] 4 Concurrent Systems and Applications A system is to support abortable transactions that operate on a data structure held only in mtrict two-phase locking (S-2PL) and how it enforces strict isolation. [4 marks] (c) What impact would changing from S-2PL to ordinary 2PL have (i) during a transaction's execution, (ii) when a transaction attempts to commit and (iii) when a transaction aborts? [6 marks] (d) You discover that the system does not perform as well as intended using S-2PL (measured in terms of the mean number of transactions that commit each second). Suggest why this may be in the following situations and describe an enhancement or alternative mechanism for concurrency control for each: (i) The workload generates frequent contention for locks. The commit rate sometimes drops to (and then remains at) zero. [2 marks] (ii) Some transactions update several objects, then perform private computation for a long period of time before making one final update. [2 marks] (iii) Contention is extremely rare. [4 marks] 3 [TURN OVER CST.2002.6.4 SECTION B 5 Comparative Programming Languages (a) Briefly discuss the compromises that must be made when standardising a programming language. [8 marks] (b) Discuss the relative merits to (1) the application programmers and (2) compiler writer of the following ways of specifying a programming language. (i) A concise readable user manual for the language in English containing many useful programming examples. (ii) A very long and highly detailed description, in English, of every feature of the language. This manual contains no programming examples. (iii) A concise but rigorous description using a formal grammar to describe the language syntax and making extensive use of mathematical notations taken from set theory, -calculus, predicate calculus and logic to describe the semantics of the language. (iv) The source code for a clean and elegant machine-independent interpretive implementation of the language.
public void add(){
ArrayList
System.out.println("Enter First name:");
String firstName = sc.next();
System.out.println("Enter Last name:");
String lastName = sc.next();
System.out.println("Enter Student ID:");
long studentID = sc.nextLong();
System.out.println("Enter date of birth (dd):");
int dd = sc.nextInt();
System.out.println("Enter month of birth (mm):");
int mm = sc.nextInt();
System.out.println("Enter year of birth (yyyy):");
int yyyy = sc.nextInt();
while(true){
System.out.println("Enter U for undergrate Student or G for Graduate Student:");
String addAnswer = sc.next().toLowerCase();
if(addAnswer.equalsIgnoreCase("u")){
System.out.println("Enter Assignment 1 mark");
int assignment1 = sc.nextInt();
System.out.println("Enter Assignment 2 mark");
int assignment2 = sc.nextInt();
System.out.println("Enter Practical Work mark");
int practicalWork = sc.nextInt();
System.out.println("Enter Final Examination mark");
int finalExam = sc.nextInt();
break;
}
else if(addAnswer.equalsIgnoreCase("G")){
System.out.println("Enter Enrollment Type:");
String enrollmentType = sc.next();
System.out.println("Enter Number of year completed:");
int yearCompleted = sc.nextInt();
System.out.println("Enter final grade:");
char finalGrade = sc.next().charAt(0);
break;
}
else{
System.out.println("Wrong Input");
}
}
String outfileName ="Student.csv";
PrintWriter writer = null;
try{
writer = new PrintWriter(outfileName);
for(int i =0; i String oneLine = students.get(i).getFirstName() +","+ students.get(i).getLastName() +","+ students.get(i).getStudentID() +","+ students.get(i).getDay()+","+ students.get(i).getMonth()+","+ students.get(i).getYear(); writer.println(oneLine); } Student obj = new Student(firstName, lastName, studentID,dd,mm,yyyy); String oneNewLine = obj.getFirstName() +","+ obj.getLastName() +","+ obj.getStudentID() +","+ obj.getDay()+","+ obj.getMonth()+","+ obj.getYear(); writer.println(oneNewLine); } catch(FileNotFoundException err) { System.out.println(err); } finally { if (writer != null){ writer.close(); } } } public void removeStudent(){ System.out.print(" Enter student id to remove: "); long id = sc.nextLong(); int pos = searchStudentID(id); if(pos == -1) System.out.println("\3n ERROR: No student found having ID: " + id); else System.out.print String answer = sc.next().toLowerCase(); if (answer.equals("y")){ System.out.println(students.get(pos).getName()); System.out.println("Student ID: " + id); students.remove(pos); }else if (answer.equals("n")){ System.out.print("Student Number was not deleted"); removeStudent(); } else{ System.out.print("Invalid input, please re-enter"); } } Add (to the ArrayList) all the marks information about an undergraduate or graduate student by reading it from another CSV file. Your program will ask for the file name. Given student number (ID), remove the specified student and relevant information from the ArrayList. ensure to address all the questions Write java program to store a positive number a user inputs until he enters 0. Print all the numbers entered at the end. Write program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Write code to repeatedly ask the user for a number. If the number is positive and even, print out a happy message. If the number is positive and odd, print out a sad message. Write Java program that reads an integer n from the keyboard and loops until 13 n 13 is successfully entered Write Java program that reads an integer n from the keyboard and prints the corresponding value n Convert this Code From Java To C++ code import java.io.File; import java.io.FileNotFoundException; import java.util.*; class Icon { private String icon; private int rowLoc; private int colLoc; public Icon(String icon, String[][] board,int boardSize){ this.icon=icon; setLocation(board, boardSize); } //Accessors public String getIcon(){return icon; } public int getRowLoc(){return rowLoc; } public int getColLoc(){return colLoc; } public void setIcon(String icon){ this.icon=icon; } public void setLocation(String[][] board,int boardSize){ for(int r=0; r for(int c=0; c if(board[r][c].equals(this.icon)){ rowLoc=r; colLoc=c; } } } } } public class Main { return " Move "+icon+" up" + solveRow(--initLoc, finLoc, icon); } // get the steps in solving the column of the icon/character public static String solveColumn(int initLoc, int finLoc, String icon){ //checks if the initial column is the same as the final column, if yes return blank string if(initLoc==finLoc) return ""; //if the final locatio is greater than initial location, Move the icon right, then call the method again while incrementing initial location else if(finLoc>initLoc) return " Move "+icon+" right" + solveColumn(++initLoc, finLoc, icon); else return " Move "+icon+" left" + solveColumn(--initLoc, finLoc, icon); } public static void main(String[] args) throws FileNotFoundException{ //initialize components Scanner scan=new Scanner(System.in); ArrayList ArrayList boolean isOK=false; //checker if the file is valid int boardSize=0; // board size holder File file=new File(""); // file holder; while(!isOK){ System.out.println("Enter file name: "); // ask the user to input file name, should be in root folder String fileName=scan.nextLine(); file=new File(fileName); Scanner fileScan=new Scanner(file); while(fileScan.hasNext()){ String tmp = fileScan.nextLine(); input.add(tmp); //add each line to input array String[] tmpSplit=tmp.split(""); //add each character to chars array for(String a:tmpSplit) chars.add(a); } fileScan.close(); boardSize=Integer.parseInt(input.remove(0)); //set the first element of input array as the boardsize and removes it chars.remove(Integer.toString(boardSize)); // remove board size character from chars array //check of boardsize matches the number of rows each board has, output a message if not if(boardSize != (input.size())/2){ System.out.println("Board Size not match"); } isOK=(boardSize != (input.size()-1)/2); } //initialize the two boards String[][] initialBoard=new String[boardSize][boardSize]; String[][] targetBoard=new String[boardSize][boardSize]; //set initial board for(int i=0; i for(int j=0; j String[] set = input.get(i).split(""); initialBoard[i][j] = set[j]; } } //set target board for(int i=boardSize ; i for(int j=0; j String[] set = input.get(i).split(""); targetBoard[i-boardSize][j] = set[j]; } } while(chars.contains("-")) chars.remove("-"); //remove all '-' characters from char array ArrayList for(String a:chars){ if(!toSolve.contains(a)) toSolve.add(a); } Collections.sort(toSolve); // sort toSolve array ArrayList ArrayList //set values for(int i=0; i initIcons.add(new Icon(toSolve.get(i), initialBoard, boardSize)); finalIcons.add(new Icon(toSolve.get(i), targetBoard, boardSize)); System.out.print(toSolve.get(i)); } String output=""; //final output to be displayed, contains the moves //solves each icon/character using solveRow and solveColumn Methods for(int i=0; i output += solveRow(initIcons.get(i).getRowLoc(), finalIcons.get(i).getRowLoc(), toSolve.get(i)); output += solveColumn(initIcons.get(i).getColLoc(), finalIcons.get(i).getColLoc(), toSolve.get(i)); } System.out.println(" "); for(int i=0; i if(i==boardSize) System.out.println(); System.out.println(input.get(i)); } scan.close(); //output the moves to solve the boards System.out.println(" "+output); } } address all qustions
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started