Using either a UNIX or a Linux system, write a C program that forks a child process that ultimately becomes a zombie process. This zombie process must remain in the system for at least 10 seconds.

Answers

Answer 1

Answer:

#include <stdlib.h>

#include <sys/types.h>

#include <unistd.h>

int main()

{

// Using fork() creates child process which is  identical to parent

int pid = fork();

 // Creating the Parent process

if (pid > 0)

 sleep(10);

// And then the Child process

else

{

 exit(0);

}

 

return 0;

}

Explanation:

Using a Text editor enter the code in the Answer section and save it as zombie.c. The created process will be able to run for 10 seconds.

Now open the Terminal and type $ cc zombie.c -o zombie to compile the program which is then saved as an executable file.

With a GNU compiler run the following command ./zombie which will give you an output of the parent process and child process to be used testing.


Related Questions

Write a SELECT statement that returns two columns based on the Vendors table. The first column, Contact, is the vendor contact name in this format: first name followed by last initial (for example, "John S.") The second column, Phone, is the VendorPhone column without the area code. Only return rows for those vendors in the 559 area code. Sort the result set by first name, then last name.

Answers

The answer & explanation for this question is given in the attachment below.

The SQL query selects vendor contacts' first names followed by last initials and phone numbers without area codes from the Vendors table. It filters vendors with the 559 area code and sorts results alphabetically by first name and last name.

Below is the SQL SELECT statement that fulfills your requirements:

```sql

SELECT

   CONCAT(SUBSTRING_INDEX(ContactName, ' ', 1), ' ', LEFT(SUBSTRING_INDEX(ContactName, ' ', -1), 1), '.') AS Contact,

   SUBSTRING(VendorPhone, 5) AS Phone

FROM

   Vendors

WHERE

   VendorPhone LIKE '559%'

ORDER BY

   SUBSTRING_INDEX(ContactName, ' ', 1),

   SUBSTRING_INDEX(ContactName, ' ', -1);

```

This query selects the ContactName column from the Vendors table, concatenates the first name and the first letter of the last name, followed by a period, to create the Contact column.

It then extracts the phone number without the area code from the VendorPhone column and stores it in the Phone column.

Finally, it filters the results to include only vendors with the 559 area code and sorts the result set by first name and last name.

The ______ network became functional in 1969, linking scientific and academic researchers across the United States. Group of answer choices ARPANET NETAMERICA INTRANET AMERINET

Answers

Answer:

The ARPANET network became functional in 1969, linking scientific and academic researchers across the United States.

Explanation:

ARPA Net is the network that has become functional in 1969 in united States. The basic purpose of this network is to link all the researchers and scientists across united states. The full form of ARPANet is Advanced Research Project Agency Network.

The importance of this network is increase because small chunks of data that are called packets has been proposed for data transmission in the network. The data is divided into small packets and send it over the network, at destination point these packets are combined together and become orignal information.

Write a method swapPairs that switches the order of values in an ArrayList of Strings in a pairwise fashion. Your method should switch the order of the first two values, then switch the order of the next two, switch the order of the next two, and so on. For example, if the list initially stores these values: {"four", "score", "and", "seven", "years", "ago"} your method should switch the first pair, "four", "score", the second pair, "and", "seven", and the third pair, "years", "ago", to yield this list: {"score", "four", "seven", "and", "ago", "years"} If there are an odd number of values in the list, the final element is not moved. For example, if the original list had been: {"to", "be", "or", "not", "to", "be", "hamlet"} It would again switch pairs of values, but the final value, "hamlet" would not be moved, yielding this list: {"be", "to", "not", "or", "be", "to", "hamlet"}

Answers

Answer:

public static void swapPairs(ArrayList strList)

{

 for(int i = 0; i < strList.size() - 1; i += 2)

 {

  String temp1 = strList.get(i);

  String temp2 = strList.get(i + 1);

  strList.set(i, temp2);

  strList.set(i + 1, temp1);

 }

}

Explanation:

Write a program that declares constants to represent the number of inches, feet, and yards in a mile. Name the constants INCHES_IN_MILE, FEET_IN_MILE, and YARDS_IN_MILE respectively. Also declare a variable named miles to represent a number of miles. Compute and display, with explanatory text, the value in inches, feet, and yards—for example: 4.0 miles is 253440.0 inches, or 21120.0 feet, or 7040.0 yards

Answers

Answer:

The cpp program for conversion is given below.

#include <iostream>

using namespace std;

 

int main() {

 

// declaring and initializing constant variables with standard values

   const  double INCHES_IN_MILE=63360;

   const  double FEET_IN_MILE=5280;

   const  double YARDS_IN_MILE=1760;

   

   // declaring and initializing miles with a random value

   double miles=4.0;

   

// declaring and computing inches in miles

double inch = INCHES_IN_MILE*miles;

 

// declaring and computing feet in miles

double feet = FEET_IN_MILE*miles;

 

// declaring and computing yards in miles

double yard = YARDS_IN_MILE*miles;

 

// displaying all the calculated values

std::cout<<miles<<" miles is "<<inch<<" inches"<<std::endl;

std::cout<<miles<<" miles is "<<feet<<" feet"<<std::endl;

       std::cout<<miles<<" miles is "<<yard<<" yards"<<std::endl;

   

       return 0;      

}

OUTPUT

4 miles is 253440 inches

4 miles is 21120 feet

4 miles is 7040 yards

Explanation:

The steps in the program are as described.

1. All the three constant variables, mentioned in the question, are declared as double and initialized. These variables hold the fixed conversion values for inches, feet and yards in one mile.

2. The variables are declared constant using the keyword, const.

3. The variable to hold value for mile, miles, is declared as double and initialized with a random value.

4. Next, three more variables are declared as double. These variables will hold the calculated values for inches, feet and yards in the given value of mile.

5. The values are calculated for inches, feet and yards for the given value of variable, miles and stored in the variables mentioned in step 3.

6. These values are displayed to the console along with explanations.

7. The program ends with the return statement.

8. The value of variable, miles, is hard coded in the program and not taken from the user.

9. There is no interaction with the user in this program as this is not mentioned in the question.

10. The program works for all numeric value of the variable, miles, since double accepts integers also.

11. The program can be tested by changing the value of variable, miles.

Using the following code, answer the following questions

1. #pragma omp parallel
2.{
3. id-omp-get thread num();
4. numThreads- omp_get num threads0
5, printf("Hello from thread %d of %din", id, numThreads);
6.}

a. What is the output of the above program in PI 3 B+? .
b. What does the statement at line 1 mean?
c. How to compile the following code (executable should not be /a out)?
d. What does the statement at line 4 (after the equal sign) mean?

Answers

Answer:

Answer explained

Explanation:

as PI 3 B+ is quadcore processor(i.e. 4 cores)

omp_get_thread_num() is used for getting thread number.(i.e. 0,1,2,3)

omp_get_num_threads() is used for getting number of threads.(i.e. 4)

1. Output should be,

Hello from thread 0 of 4

Hello from thread 1 of 4

Hello from thread 2 of 4

Hello from thread 3 of 4

2. #pragma omp parallel is used to fork(create child) additional threads to carry out the work enclosed in the construct in parallel.

3. We can Compile this code using,

  gcc -o omp_helloc -fopenmp hello.c

4. We can Run this code using,

   ./hello

5.omp_get_num_threads() is used for getting number of threads.(i.e. 4)

A company ABC asked you to design a simple payroll program that calculates and employee's weekly gross pay, including any overtime wages. If employees work over 40 hours in a week, they will get 1.5 times of their regular hourly rate for all hours over 40. Your program asks the user to input hours worked for a week, regular hourly rate, and then display the weekly gross pay. Draw the Raptor flowchart to represent the logic of the problem. Name the Raptor flowchart file as lab5.rap. Output sample Enter weekly hours worked: 35 Enter hourly rate: 30 Weekly gross pay: $ 1050 Output sample Enter weekly hours worked: 50 Enter hourly rate: 30 Weekly gross pay: $ 1650

Answers

Answer:

C++.

#include <iostream>

using namespace std;

////////////////////////////////////////////////////////////////

int main() {

   int weekly_hours = 0;

   int hourly_rate;

   float gross_pay = 0;

   cout<<"Enter weekly hours worked: ";

   cin>>weekly_hours;

   

   cout<<"Enter hourly rate: ";

   cin>>hourly_rate;

   

   cout<<endl;

   ////////////////////////////////////////////////

   if (weekly_hours > 40) {

       gross_pay = (weekly_hours*hourly_rate) + ((weekly_hours*hourly_rate)*0.5);

   }

   else

       gross_pay = weekly_hours*hourly_rate;

       

   cout<<"Weekly gross pay: $"<<gross_pay;

   ////////////////////////////////////////////////

   return 0;

}

Write two functions called permutation() and combination(), where permutation() computes and returns n!/(n-r)!whereas combination() returns. n!/(n-r)!r!A third function called par_input() gets the input values for n and r. An example of correct program behavior follows: Input: 3 2 Output: The permutation is 6, and the combination is 3.

Answers

Answer:

Here is the program in C.

#include<stdio.h>   // header file used to input output operations

int permutation(int n, int r);  // function to computer permutation

int combination(int n, int r);  //function to compute combination

int factorial(int number);  // function to computer factorial

void par_input(int n, int r);    // function take take input value of n and r

int main()  //start of main() function body

{    

   int n,r;  // declare n and r variables

   par_input(n,r);  //calls par_input() function to get values of n and r

}

 

int permutation(int n, int r)   // method to calculate permutation

{

   return factorial(n) / factorial(n-r);  //formula for permutation

}

 

int combination(int n, int r)  // method to calculate combination

{

   return permutation(n, r) / factorial(r); //formula for combination

}

 

int factorial(int number)  // to find factorial of a number

{

   int fact = 1;      

   while(number > 0)  //loop continues until value of number gets <=0

   {

       fact = fact *number;  

       number--;

   }      

   return fact;

}

void par_input(int n, int r)  //function to take input values

{

   printf("Enter n: ");  //prompts user to enter the value of n

   scanf("%d", &n);      //reads the value of n from user

   printf("Enter r: "); ////prompts user to enter the value of r

   scanf("%d", &r); //reads the value of r from user

  //calls the combination and permutation methods to display results

   printf("The permutation is = %d\n", permutation(n, r));    

   printf("The Combination is = %d", combination(n, r));      

}

Explanation:

The main() function calls par_input() function. This function asks user to enter values of n and r and then calls permutation() and combination() methods to compute the combination and permutation using these input values. Lets say user enters n=3 and r=2The permutation() function computes and returns permutation using the following formula: n! / (n-r)! factorial(n) / factorial(n-r); This function calls factorial method which calculates the factorial of n and n-r.This function then returns the permutation.3! / (3-2)! = 3*2*1 / 1! = 6Next the combination() function computes and returns combination using the following formula: n! / r! * (n - r)!permutation(n, r) / factorial(r)This function calls permutation() and factorial() methods which calculate the combination of n and n-rThis function then returns the combination.3! / 2! * (3-2)! = 3*2*1 / 2*1 * 1 = 6 / 2 = 3 Factorial function computes and returns the factorial of n, r and n-r.Lets take n! When n=3 So this function computes factorial as follows:while loops checks if number>0 It is true as number is 3It multiplies 3 by fact. fact is initialized to 1 So1*3 = 3Then it decreases number=3 by 1 so number=2Now while loops checks if number>0 It is true as number is 2It multiplies 2 by fact. Value of fact is now 3 So3*2 = 6Then it decreases number=2 by 1 so number=1Now while loops checks if number>0 It is true as number is 1It multiplies 1 by fact. Value of fact is now 6 So6*1 = 6Then it decreases number=1 by 1 so number=0Now while loops checks if number>0 It is false as number is 0So the loop breaks and the value of fact is returned.As fact= 6 So factorial of n is 6.

The output of the program is attached in the screen shot.

Your friend is an intern at the local Department of Health and needs to prepare a report about the recent activity of the influenza virus. She has recorded the number of cases of each type of flu (A, B, and C) over the last several weeks. Write a C program that will calculate the total cases for each week, determine the level of activity for the week (low, moderate, or widespread) and print a report to a file, including a small bar chart for the weekly cases.

Answers

Answer:

#include<bits/stdc++.h>

using namespace std;

int main(){

  // Defining Variables

  int no_of_weeks;

  int total_cases = 0;

  //Declaring Vector of Pair of Integer and string

  std::vector<pair<int,string>> data;

  // Taking Input for the Number of Weeks

  cout<<"Enter No. of Weeks\n";

  cin >> no_of_weeks;

  // Running the Loop for no_of_weeks times

  for(int i = 0; i < no_of_weeks ; i++){

      int A,B,C;

      // Taking Input for different types of flus

      cout<<"Enter No. of Cases of Flu A, B, C for week" << i + 1 << " seperated by space : \n";

      cin >> A >> B >>C;

      // Adding all the cases in a week

      int cases_in_a_week = A + B + C;

      // Updating total cases

      total_cases += cases_in_a_week;

      // Declaring the level variable

      string level;

      // Updating the level of the week corresponding to each case

      if(cases_in_a_week < 500) level = "Low";

      else if(cases_in_a_week >= 500 && cases_in_a_week < 2000) level = "Moderate";

      else level = "Widespread";

      // Storing the Week's information by using a vector of pairs

      // in which pair's first is the number of cases which is of type int

      // while the second is the level of the flu which is of the type string

      data.push_back(make_pair(cases_in_a_week,level));

  }

  // Linking the stdoutput to the flu_report.txt file

  // this also creates the file with the same name if it doesn't exists

  freopen("flu_report.txt", "w", stdout);

  // Printing the respective output data with Bar Chart of stars for each level

  for(int i = 0;i < no_of_weeks ; i++){

      //printing the week no. and number of cases

      cout<<i+1<<" "<<data[i].first<<" "<<data[i].second<<" |";

      //calculating the number of stars

      int stars = data[i].first/250;

      //printing the stars of the bar chart

      for(int j = 0; j < stars ; j++) cout<<"*";

      cout<<endl;

  }

  //printing the total number of cases

  cout<<total_cases;

}

Explanation:

Answer:

C code explained below

Explanation:

I have provided the proper commented code below.

I hope that you find the answer helpful.

CODE:

-------------------------------------------------------------------------------------------------------------

#include<bits/stdc++.h>

using namespace std;

int main(){

  // Defining Variables

  int no_of_weeks;

  int total_cases = 0;

  //Declaring Vector of Pair of Integer and string

  std::vector<pair<int,string>> data;

  // Taking Input for the Number of Weeks

  cout<<"Enter No. of Weeks\n";

  cin >> no_of_weeks;

  // Running the Loop for no_of_weeks times

  for(int i = 0; i < no_of_weeks ; i++){

      int A,B,C;

      // Taking Input for different types of flus

      cout<<"Enter No. of Cases of Flu A, B, C for week" << i + 1 << " seperated by space : \n";

      cin >> A >> B >>C;

      // Adding all the cases in a week

      int cases_in_a_week = A + B + C;

      // Updating total cases

      total_cases += cases_in_a_week;

      // Declaring the level variable

      string level;

      // Updating the level of the week corresponding to each case

      if(cases_in_a_week < 500) level = "Low";

      else if(cases_in_a_week >= 500 && cases_in_a_week < 2000) level = "Moderate";

      else level = "Widespread";

      // Storing the Week's information by using a vector of pairs

      // in which pair's first is the number of cases which is of type int

      // while the second is the level of the flu which is of the type string

      data.push_back(make_pair(cases_in_a_week,level));

  }

  // Linking the stdoutput to the flu_report.txt file

  // this also creates the file with the same name if it doesn't exists

  freopen("flu_report.txt", "w", stdout);

  // Printing the respective output data with Bar Chart of stars for each level

  for(int i = 0;i < no_of_weeks ; i++){

      //printing the week no. and number of cases

      cout<<i+1<<" "<<data[i].first<<" "<<data[i].second<<" |";

      //calculating the number of stars

      int stars = data[i].first/250;

      //printing the stars of the bar chart

      for(int j = 0; j < stars ; j++) cout<<"*";

      cout<<endl;

  }

  //printing the total number of cases

  cout<<total_cases;

}

Once sales are​ forecasted, ________ must be generated to estimate required raw materials. A. a pro forma statement B. a production plan C. a cash budget

Answers

Answer:

Option B i.e., a production plan.

Explanation:

While sales are estimated, the manufacturing schedule for estimating the necessary raw materials should be produced.

So when the revenue is already estimated then at that time the manufacturing schedule should be produced approximately that raw material which is needed, so the following option is correct according to the scenario.

Option a is incorrect because it is not related to the following scenario.Option B is incorrect because in the above statement, it is not mentioned or related to the budget plan.

Craig likes to work on his computer at his local coffee shop, but people around him may be able to see what he is doing, including entering passwords for his accounts. This method of gaining confidential information is referred to as ________.

(A) phishing
(B) shoulder surfing
(C) man-in-the-middle attacks
(D) spear phishing

Answers

Answer:

B

Explanation:

Craig could of left the coffee shop but instead he could just shoulder surfing so no one could see all the other options are just plain Wrong shoulder surfing can do no harm

Define the body of the function read_data(filename). If filename is None, return the sentence (already defined for your), otherwise return the contents of the file (whose name is in the parameter filename). If there is any error during the opening or reading of the file, print out a warning and return sentence. If you haven't completed the lesson on Python local I/O, do so now.

Answers

Answer:

Answer explained

Explanation:

The main difference between parse_text_into_words( v1 and v2) is I have used splitlines also in v1 so the escape sequence '\n' will not be present in the list of words. while in v2 only split function is used so it will have '\n' present in words list.

Code:

def read_file(fileName = None):

  try:

      File = open(fileName,"r") # opening file in read mode

      for row in File:          # for each line in File

          print(row,end="")

  except IOError:      # handling exception of file opening

      print("Could not read file:",fileName)

def parse_text_into_words_v1(text):

  list_words = []

  list_lines = text.splitlines()

  for i in list_lines:

      list_words.extend(i.split(' '))

  return list_words

def parse_text_into_words_v2(text):

  list_words = []

  list_words.extend(text.split(' '))

  return list_words

def determine_difference(a_list,b_list):

  print("first list:",a_list)

  print("second list:",b_list)

  a_set = set(a_list)

  b_set = set(b_list)

  diff = a_set - b_set

  diff = list(diff)

  print("\nDifference between 2 sets: ",diff)

if __name__ == '__main__':

  print("Reading file using function read_file() to read \"data.txt\" :")

  read_file("data.txt")

  print("\n\n")

  t = '''vhfhyh ghgggj ghchvjhvj'''

  print("\nDemonstrating implementation of parse_text_into_words_v1:")

  l = parse_text_into_words_v1(t) # calling function with text parameter

  print("list of words:")

  print(l)

  print("\nDemonstrating implementation of parse_text_into_words_v2:")

  b = parse_text_into_words_v2(t) # calling function with text parameter

  print("list of words:")

  print(b)

  print("\nDemonstrating difference between two lists")

  a_list = [1,2,3,4,5,6,7,8,9,10]

  b_list = [2,4,6,8,10]

  determine_difference(a_list,b_list) # passing two list to take difference

When your phone sends/receives text messages (specifically using SMS), the total data sent/received contains more than just your 160-character message. What is an example of this additional data, and why is it included

Answers

An SMS is a short code that is used by businesses to opt in consumers to their SMS programs, and then used to send text message coupons, offers, promotions to those customers that had previously opted.

Explanation:

When Someone tries to call you, the tower sends your phone a message over the control channel that tells your phone to play its ringtone. The tower gives your phone a pair of voice channel frequencies to use for the call.

The MMS and other data driven services works on the fundamental voice network and is based on the big three GSM, CDMA and TDMA network technologies. The SMS allows text messages of 160 characters (letters, numbers and symbols).

The text messaging is an act of composing and sending electronic messages consist of alphabetic and numeric character between two or more more mobile devices.

SMS stands for short messaging service, it refers to a protocol that is used for sending short messages over wireless networks.

SMS works on the fundamental principle voice network, and is based on the three big technologies (i.e. GSM, CDMA and TDMA) which makes it a universal service.

Explanation:

Data SMS messages are sent through the data network, using the  2G / 3G/4G  data connection.

A perfect example for data SMS use is when your recipient has  pay to receive the  text message even though they  may have unlimited texting. By using a data SMS service, all extra charges are avoided and the amount of data used by SMS messages is insignificant compared to even lite web page viewing.

Data SMS messages are sent not only through the data network (over your 2G / 3G data connection), but also through GSM as Text SMS.

The PDU of a text message has a User Data Headers (UDH) that defines a specific port on a handset

Choose two prime numbers p and q (these are your inputs). Suppose that you need to send a message to your friend, and you implement the RSA algorithm for secure key generation. You need public and private keys (these are your outputs). You are free to choose other parameters or inputs if you need any. Write a program for the RSA algorithm using any programing language you know (such as C++) to generate your public and private key.

Answers

Answer:

#include <iostream>

#include<math.h>

using namespace std;

int findGcd(int x, int y) {

int t;

while(1) {

t= x%y;

if(t==0)

return y;

x = y;

y= t;

}

}

int main() {

int v1,v2,p,q,flag = 0;

cout<<"Please enter 1st prime number: ";

cin>>p;

v1 = p/2;

cout<<"Please enter 2nd prime number: ";

cin>>q;

v2 = q/2;

for(int i = 2; i <= v1; i++)

{

if(p%i == 0)

{

cout<<"The number is not prime";

flag = 1;

return 0 ;

}

}

for(int i = 2; i <= v1; i++)

{

if(q%i == 0)

{

cout<<"You entered a number which is not prime";

flag = 1;

return 0;

}

}

double n=p*q;

double tr;

double phi= (p-1)*(q-1);

double e=7;

if( flag == 0)

{

while(e<phi) {

tr = findGcd(e,phi);

if(tr==1)

break;

else

e++;

}

cout<<"public key: "<<e<<endl;

double d1=1/e;

double d=fmod(d1,phi);

cout<<"private key: "<<d<<endl;

double message;

cout<<"please enter a message: ";

cin>>message;

double cipher = pow(message,e);

double m = pow(cipher,d);

cipher = fmod(cipher,n);

m = fmod(m,n);

cout<<"Encrypted message: "<<cipher;

}

}

Explanation:

Find n = p*q and calculate phi = (p-1) * (q-1). Select a number e such that 1 < e < phi(n) and findGcd(e, phi(n)) = 1. Find d which is private key  as d = e−1 (mod phi(n)).As m is original message so encrypt using, cipher = m*e mod n.

Which of the following statement is true?

a. the MAC address cannot be spoofed
b. the IP address can be spoofed, so if you want to read response from the deceived party, you can use
c. IP spoofing to hide yourself IP spoofing can be used for denial of service attack
d. IP spoofing can be prevented or detected by switches

Answers

Answer:

b. the IP address can be spoofed, so if you want to read response from the deceived party, you can use IP spoofing to hide yourself.

Explanation:

You need to write a program that reads in the mass of an object (in kg) and output the weight (in N) on the Earth, on the Moon, and on Venus. An object's mass can be measured in kilograms. The weight is measured in newtons. So an object of a specific mass (in kilograms) would have one weight (in newtons) on the earth and a different weight on the moon. Your program will read in the mass (in kilograms) and convert it to newtons for the Earth, the Moon, and Venus. So, on the Earth we can convert kilograms to newtons with the following expression: weight = mass * 9.81 where 9.81 is the acceleration due to gravity on earth (in meters per second squared or m/s^2). On the Moon this formula would be: weight = mass * 1.62 where 1.62 is the acceleration due to gravity on the moon (m/s^2) Finally, for Venus it would be: weight = mass * 8.87

Answers

Answer:

#include <iostream>

#include<iomanip>

using namespace std;

int main()

{

double mass,e,m,v;

cout<<"Enter the mass : ";

cin>>mass;

cout<<"The mass is "<<mass<<" kg\n";

if(mass<=0){

cout<<" mass must be greater than zero";

return 0;

}

e= mass * 9.81;

m= mass * 1.62;

v = mass * 8.87;

cout.setf(ios::fixed);

cout<<"Location"<<right<<setw(10)<<"Weight\n";

cout<<"Earth"<<right<<setw(15)<<setprecision(4)<<e<<endl;

cout<<"Moon"<<right<<setw(15)<<setprecision(4)<<m<<endl;

cout<<"Venus"<<right<<setw(15)<<setprecision(4)<<v<<endl;

cout<<endl<<endl;

if(m>=1500)

cout<<"Object is light weight";

else

cout<<"Object is heavy weight";

}

Explanation:

Final answer:

An object's weight is calculated by multiplying its mass by the acceleration due to gravity, which varies by celestial body. On Earth, the weight is the mass times 9.81 m/s², while on the Moon it is mass times 1.62 m/s², and on Venus, the weight is calculated with an acceleration due to gravity of 8.87 m/s².

Explanation:

The mass of an object is a measure of the amount of matter in that object and does not change regardless of the object's location. On the other hand, weight is the force exerted by gravity on an object and is calculated by multiplying the mass (in kilograms) by the acceleration due to gravity (in meters per second squared, m/s²). This acceleration due to gravity varies depending on the celestial body.

On Earth, the acceleration due to gravity is approximately 9.81 m/s², which means that an object's weight can be calculated as its mass multiplied by 9.81. For example, a mass of 100 kg on Earth would have a weight of 981 Newtons (N).

The Moon's gravitational acceleration is much lower, around 1.62 m/s². Thus, the same 100 kg object would weigh 162 N on the Moon. It's clear that, although mass remains consistent, weight varies significantly depending on the acceleration due to gravity at the location.

Similarly, on Venus, the acceleration due to gravity is 8.87 m/s². To find the weight of an object on Venus, you multiply its mass by this acceleration. So, a 100 kg object would weigh approximately 887 N on Venus.

The distinction between mass and weight is important as it highlights that weight can change locationally due to variations in gravitational pull, while mass is an intrinsic property of an object that does not change with location.

Using a while loop, write a code that will continue to calculate the following equation until the solution gets to be above 100, x will start at zero. What is the final solution and how many iterations does it take to complete (prob05) as a row vector.

Answers

Answer:

prob05.m

clc

x=0;

sum=0;

iteration=0;

while (sum<100)

x=2*x+1;

sum=sum+x;

x=x+1;

iteration=iteration+1;

end

fprintf('total iteraton take to sum greater than 100 is %d and sum becomes %d\n',iteration,sum);

Explanation:

Create a C# GUI Windows Form application named JobDemo that declares and uses Job objects. The Job class holds job information for a home repair service. The class has five properties that include a job number, customer name, job description, estimated hours, and price for the job. Create a constructor that requires parameters for all the data except price. Include auto-implemented properties for the job number, customer name, and job description, but not for hours or price; the price field value is calculated as estimated hours times $45.00 whenever the hours value is set.

Also create the following for the class:

An Equals() method that determines two Jobs are equal if they have the same job number A ToString() method that returns a string containing all job information

The JobDemo Windows Form declares a few Job objects, sets their values, and demonstrates that all the methods work as expected.

Using the Job class you created in (a), write a new application named JobDemo2 that creates an array of five Job objects. Prompt the user for values for each Job. Do not allow duplicate job numbers; force the user to reenter the job when a duplicate job number is entered. When five valid objects have been entered (use List), display them all, plus a total of all prices.

Create a RushJob class that derives from Job. A RushJob has a $150.00 premium that is added to the normal price of the job. Override any methods in the parent class as necessary. Create a new Windows Form named JobDemo3 that creates an a List of five RushJobs. Prompt the user for values for each, and do not allow duplicates

Create a RushJob class that derives from Job. A RushJob has a $150.00 premium that is added to the normal price of the job. Override any methods in the parent class as necessary. Write a new Windows Form named JobDemo3 that creates a List of five RushJobs. Prompt the user for values for each, and do not allow duplicate job numbers. When five valid RushJob objects have been entered, display them all, plus a total of all prices. Make any necessary modifications to the RushJob class so that it can be sorted by job number.

Answers

Here's the implementation for the requested tasks:

### Job Class

```csharp

using System;

public class Job

{

   private static int nextJobNumber = 1;

   public int JobNumber { get; }

   public string CustomerName { get; set; }

   public string JobDescription { get; set; }

   public double EstimatedHours { get; set; }

   public double Price => EstimatedHours * 45.00;

   public Job(string customerName, string jobDescription, double estimatedHours)

   {

       JobNumber = nextJobNumber++;

       CustomerName = customerName;

       JobDescription = jobDescription;

       EstimatedHours = estimatedHours;

   }

   public override bool Equals(object obj)

   {

       if (obj == null || GetType() != obj.GetType())

       {

           return false;

       }

       Job otherJob = (Job)obj;

       return JobNumber == otherJob.JobNumber;

   }

   public override int GetHashCode()

   {

       return JobNumber.GetHashCode();

   }

   public override string ToString()

   {

       return $"Job Number: {JobNumber}, Customer Name: {CustomerName}, Job Description: {JobDescription}, Estimated Hours: {EstimatedHours}, Price: {Price:C}";

   }

}

```

### JobDemo Form

```csharp

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace JobDemo

{

   public partial class JobDemoForm : Form

   {

       private List<Job> jobs = new List<Job>();

       public JobDemoForm()

       {

           InitializeComponent();

       }

       private void addButton_Click(object sender, EventArgs e)

       {

           string customerName = customerNameTextBox.Text;

           string jobDescription = jobDescriptionTextBox.Text;

           double estimatedHours;

           if (double.TryParse(estimatedHoursTextBox.Text, out estimatedHours))

           {

               Job job = new Job(customerName, jobDescription, estimatedHours);

               if (!jobs.Contains(job))

               {

                   jobs.Add(job);

                   outputListBox.Items.Add(job.ToString());

                   totalLabel.Text = $"Total: {CalculateTotal():C}";

               }

               else

               {

                   MessageBox.Show("Duplicate job number. Please enter a unique job number.");

               }

           }

           else

           {

               MessageBox.Show("Invalid estimated hours. Please enter a valid number.");

           }

       }

       private double CalculateTotal()

       {

           double total = 0;

           foreach (var job in jobs)

           {

               total += job.Price;

           }

           return total;

       }

   }

}

```

### RushJob Class

```csharp

public class RushJob : Job, IComparable<RushJob>

{

   private const double RushJobPremium = 150.00;

   public RushJob(string customerName, string jobDescription, double estimatedHours)

       : base(customerName, jobDescription, estimatedHours)

   {

   }

   public override double Price => base.Price + RushJobPremium;

   public int CompareTo(RushJob other)

   {

       return JobNumber.CompareTo(other.JobNumber);

   }

}

```

### JobDemo3 Form

```csharp

using System;

using System.Collections.Generic;

using System.Linq;

using System.Windows.Forms;

namespace JobDemo

{

   public partial class JobDemo3Form : Form

   {

       private List<RushJob> rushJobs = new List<RushJob>();

       public JobDemo3Form()

       {

           InitializeComponent();

       }

       private void addButton_Click(object sender, EventArgs e)

       {

           string customerName = customerNameTextBox.Text;

           string jobDescription = jobDescriptionTextBox.Text;

           double estimatedHours;

           if (double.TryParse(estimatedHoursTextBox.Text, out estimatedHours))

           {

               RushJob rushJob = new RushJob(customerName, jobDescription, estimatedHours);

               if (!rushJobs.Any(rj => rj.JobNumber == rushJob.JobNumber))

               {

                   rushJobs.Add(rushJob);

                   outputListBox.Items.Add(rushJob.ToString());

                   totalLabel.Text = $"Total: {CalculateTotal():C}";

               }

               else

               {

                   MessageBox.Show("Duplicate job number. Please enter a unique job number.");

               }

           }

           else

           {

               MessageBox.Show("Invalid estimated hours. Please enter a valid number.");

           }

       }

       private double CalculateTotal()

       {

           double total = 0;

           foreach (var rushJob in rushJobs)

           {

               total += rushJob.Price;

           }

           return total;

       }

   }

}

This code should fulfill the requirements you've specified. Let me know if you need further assistance!

Write a Python program to: ask the user to enter the price of an item. Note: use a while loop to check the validity of the price and, if the user enters a price less than or equal to zero, to prompt for a valid price. Prompt the user for the quantity being purchased. If the quantity is ten or greater, apply a discount of 5 percent. (.95*price*quantity).

Answers

Answer:

Hi there Tonyhh! Please find the implementation below.

Explanation:

You can save the below code in a file called "price_discount.py". The code is implemented in python 2.0+. To make it work in Python 3.0+, simply update the code to use "input" rather than "raw_input".

price_discount.py

def calculate_discount(price, quantity):

 total = 0.95 * price * quantity;

 return total;

price = raw_input("Enter a price: ");

try:

 price = int(price);

 while price <= 0:

   print("Input a valid number: ")

   price = raw_input("Enter a price: ");

 quantity = raw_input("Enter a quantity: ");

 try:

   quantity = int(quantity);

   if quantity >= 10:

     print(calculate_discount(price, quantity));

 except ValueError:

   print("Invalid quantity!")

except ValueError:

 print("Invalid input!");

 price = -1;

Design the logic and write the Java code that will use assignment statements to: Calculate the profit (profit) as the retail price minus the wholesale price Calculate the sale price (salePrice) as 25 percent deducted from the retail price Calculate the sale profit (saleProfit) as the sale price minus the wholesale price.

Answers

Answer:

Logic:

profit = retailPrice - wholeSalePrice

salePrice = retailPrice - (0.25 * retailPrice)

saleProfit = salePrice - wholeSalePrice

Java code:

double retailPrice, wholeSalePrice;

double profit = retailPrice - wholeSalePrice;

double salePrice = retailPrice - (0.25 * retailPrice);

double saleProfit = salePrice - wholeSalePrice;

Explanation:

The logic just represented the words in equation format. That is, profit is retailPrice minus wholesaleprice.

SalePrice is 25% deducted from retail price.

SaleProfit is saleprice minus wholesaleprice.

The whole logic is then represented in Java assignment statement using type double.

Write a function called name_facts that will take a firstname (string) as an input parameter, and print out various facts about the name, including:
1) its length, 2) whether it starts with the letter A, and 3) whether it contains a Z or X.
To gain full credit for this exercise, you must use string formatting to print out the result. Hints: You will probably want to convert the string to lowercase when checking conditions 2 and 3. You can get by without it, but you'll have to make sure you check both lower and uppercase versions of the letters. You will have to use the in operator for condition 3. You will also probably want to make a separate message for conditions 2 and 3 (depending on the answer) and use string formatting to join them into the final message.

Answers

Answer:

def name_facts(firstname):

   print("Your name is",len(firstname),"letters long",end=", ")

   if(firstname[0] == 'A'):

       print("does start with the letter A",end=", ")

   else:

       print("does not start with the letter A", end=", ")

   if(firstname.count('Z')>0 or firstname.count('X')>0):

       print("and does not contain a Z or X")

   else:

       print("and does not contain a Z or X")

#Testing

name_facts("Allegra")

name_facts("Xander")

Explanation:

Answer:

// Comments are used for explanatory purpose

// Program starts here

#include<iostream>

using namespace std;

int main()

{

// Declare firstname

string firstname;

//Prompt to enter firstname

cout<<"What's your first name: ";

// Accept input

cin>>firstname;

// A. Get string's length

int length = firstname.length();

// Print length

cout<<"Length = "<<length<<endl;

// Copy string to chat array

char char_array[length + 1];

// copying the contents of the string to char array

strcpy(char_array, firstname.c_str());

// B. Check if it starts with letter A

if(char_array[0] == 'A')

{

cout<<"Your Firstname begins with letter A"<<endl;

}

else

{

cout<<"Your Firstname doesn't begin with letter A"<<endl;

}

// Check if it contains X or Z

int k = 0;

for (int i = 0; i < n; i++) {

if(char_array[i] == 'Z' || char_array[i] == 'X')

{

k++;

}

if(k == 0)

{cout<<"Your Firstname doesn't contain Z or X";}

else

{cout<<"Your Firstname contains Z or X";}

}

return 0;

}

convert the following c code to mips. assume the address of base array is associated with $s0, n is associated with $s1, position is associated with $t0, c is associated with $t1, d is associated with $t2, and swap is associated with $t3 for (c

Answers

Answer:

Explanation:

hello we will follow a step by step process for this code, i hope you find it easy.

Mips Equivalent code:

  sw      $0,0($fp)

.L7:

       lw      $2,12($fp)

       addiu   $2,$2,-1

       lw      $3,0($fp)

       slt     $2,$3,$2

       beq     $2,$0,.L2

       nop

       lw      $2,0($fp)

       sw      $2,8($fp)

       lw      $2,0($fp)

       addiu   $2,$2,1

       sw      $2,4($fp)

.L5:

       lw      $3,4($fp)

       lw      $2,12($fp)

       slt     $2,$3,$2

       beq     $2,$0,.L3

       nop

       lw      $2,8($fp)

       dsll    $2,$2,2

       daddu   $2,$fp,$2

       lw      $3,24($2)

       lw      $2,4($fp)

       dsll    $2,$2,2

       daddu   $2,$fp,$2

       lw      $2,24($2)

       slt     $2,$2,$3

       beq     $2,$0,.L4

       nop

       lw      $2,4($fp)

       sw      $2,8($fp)

.L4:

       lw      $2,4($fp)

       addiu   $2,$2,1

       sw      $2,4($fp)

       b       .L5

       nop

.L3:

       lw      $3,8($fp)

       lw      $2,0($fp)

       beq     $3,$2,.L6

       nop

       lw      $2,0($fp)

       dsll    $2,$2,2

       daddu   $2,$fp,$2

       lw      $2,24($2)

       sw      $2,16($fp)

       lw      $2,8($fp)

       dsll    $2,$2,2

       daddu   $2,$fp,$2

       lw      $3,24($2)

       lw      $2,0($fp)

       dsll    $2,$2,2

       daddu   $2,$fp,$2

       sw      $3,24($2)

       lw      $2,8($fp)

       dsll    $2,$2,2

       daddu   $2,$fp,$2

       lw      $3,16($fp)

       sw      $3,24($2)

.L6:

    lw      $2,0($fp)

       addiu   $2,$2,1

       sw      $2,0($fp)

       b       .L7

        nop

cheers  i hope this helps

Convert C code to MIPS assembly using registers for array operations and loops, implementing selection sort for efficient sorting of array elements.

To convert the given C code snippet to MIPS assembly, we need to translate each part of the algorithm into MIPS instructions while considering the provided register assignments.

1. Initialization:

  -Registers: `$s0` holds the base address of the array, `$s1` holds `n`, `$t0` holds `position`, `$t1` holds `c`, `$t2` holds `d`, and `$t3` holds `swap`.

2. Outer Loop (`for c`):

  - Use a label (`outer_loop`) to mark the start of the outer loop.

  - Initialize `c` to `0` and check if `c < n - 1`.

  - Increment `c` after each iteration.

3. Inner Loop (`for d`):

  - Inside the outer loop, set `position` to `c`.

  - Use another label (`inner_loop`) to mark the start of the inner loop.

  - Initialize `d` to `c + 1` and check if `d < n`.

  - Compare `array[position]` with `array[d]` and update `position` if `array[d]` is smaller.

4.Swap Condition:

  - After the inner loop, check if `position` is not equal to `c`.

  - If true, swap `array[c]` and `array[position]` using `$t3` (`swap`) as a temporary register.

5. Assembly Code:

 assembly

  # Register assignments:

  # $s0 - base address of array

  # $s1 - n

  # $t0 - position

  # $t1 - c

  # $t2 - d

  # $t3 - swap  

  # Outer loop (for c)

  li $t1, 0          # c = 0

  outer_loop:

      blt $t1, $s1, end_outer_loop  # if c >= n, exit outer loop      

      # Inner loop (for d)

      move $t0, $t1    # position = c

      addi $t2, $t1, 1 # d = c + 1

      inner_loop:

          blt $t2, $s1, end_inner_loop  # if d >= n, exit inner loop          

          # Load array[position] and array[d]

          lw $t4, 0($s0)           # $t4 = array[position]

          lw $t5, 0($s0)($t2)      # $t5 = array[d]          

          # Compare array[position] > array[d]

          bgt $t4, $t5, update_position

          j next_iteration_inner_loop

          update_position:

              move $t0, $t2  # position = d        

          next_iteration_inner_loop:

              addi $t2, $t2, 1  # d++

              j inner_loop      

      end_inner_loop:      

      # Swap if position != c

      bne $t0, $t1, swap_elements

      j next_iteration_outer_loop      

      swap_elements:

          lw $t3, 0($s0)($t1)     # $t3 = array[c]

          lw $t4, 0($s0)($t0)     # $t4 = array[position]        

          # Swap array[c] and array[position]

          sw $t4, 0($s0)($t1)     # array[c] = array[position]

          sw $t3, 0($s0)($t0)     # array[position] = swap      

      next_iteration_outer_loop:

          addi $t1, $t1, 1  # c++

          j outer_loop      

  end_outer_loop:

  - Explanation: The MIPS assembly code mirrors the logic of the C code by using load (`lw`) and store (`sw`) instructions to access array elements, branches (`bgt`, `bne`, `blt`) for conditional logic, and loops (`j`) to control flow. It effectively implements the selection sort algorithm to sort the array in ascending order.  

  - Efficiency: This implementation efficiently sorts the array in-place using O(n^2) time complexity, suitable for moderately sized arrays given the constraints of MIPS architecture.

Complete Question;

convert the following c code to mips. assume the address of base array is associated with $s0, n is associated with $s1, position is associated with $t0, c is associated with $t1, d is associated with $t2, and swap is associated with $t3 for

for ( c = 0 c < (n - 1) c++)

{

position = c

for ( d = c + 1 d < n d ++)

{ if (array[position] > array[d])

position = d

}

if (position != c)

{

swap array[c];

array[c] = array[position];

array[position] = swap;

}

}

Chapter 4 is called Claimed Spaces: ""Preparatory Privilege"" and High School Computer Science. Explain two concepts from chapter 4 that create ‘claimed spaces’ (2-3 sentences). Describe an example from your own experience of a claimed space (2-3 sentences)

Answers

Answer: isolation, predominant gender.

Explanation:

Isolation some students felt they were not as smart as their peers and as such were afraid to make contributions because they didn't want to be rediculed by Their peers or tutors.

Predominant gender most calsses are dominated by a certain gender which makes the other gender harbour fears and insecurity

I had difficulty in maths in high school, was always afraid when in class to make contributions because i was insecure, if i had spoken up or met my tutors maybe i would have being better at it

Write a function addOddMinusEven that takes two integers indicating the starting point and the end point. Then calculate the sum of all the odd integers minus the sum of all even integers between the two points. The calculation includes the starting point but excludes the end point. You can always assume the starting point is smaller than the end point.

Answers

Answer:g

   public static int addOddMinusEven(int start, int end){

       int odd =0;

       int even = 0;

       for(int i =start; i<end; i++){

           if(i%2==0){

               even = even+i;

           }

           else{

               odd = odd+i;

           }

       }

       return odd-even;

   }

}

Explanation:

Using Java programming language:

The method addOddMinusEven() is created to accept two parameters of ints start and endUsing a for loop statement we iterate from start to end but not including endUsing a modulos operator we check for even and oddsThe method then returns odd-evenSee below a complete method with a call to the method addOddMinusEven()

public class num13 {

   public static void main(String[] args) {

       int start = 2;

       int stop = 10;

       System.out.println(addOddMinusEven(start,stop));

   }

   public static int addOddMinusEven(int start, int end){

       int odd =0;

       int even = 0;

       for(int i =start; i<end; i++){

           if(i%2==0){

               even = even+i;

           }

           else{

               odd = odd+i;

           }

       }

       return odd-even;

   }

}

Write a setInterval() function that increases the count by 1 and displays the new count in counterElement every 100 milliseconds. Call clearInterval() to cancel the interval when the count displays 4.

Answers

Answer:

var count = 0;

var counterElement = document.getElementById("counter");

counterElement.innerHTML = count;

var interval = setInterval(function () {

   count++;

   counterElement.innerHTML = count;

   if (count === 4) {

       clearTimeout(interval);

   }

}, 100);

Explanation:

In this assignment, you will model the game of Bulgarian Solitaire. The game starts with 45 cards. (They need not be playing cards. Unmarked index cards work just as well.) Randomly divide them into some number of piles of random size. For example, you might start with piles of size 20, 5, 1, 9, and 10. In each round, you take one card from each pile, forming a new pile with these cards. For example, the sample starting configuration would be transformed into piles of size 19, 4, 8, 10, and 5. The solitaire is over when the piles have size 1, 2, 3, 4, 5, 6, 7, 8, and 9, in some order. (It can be shown that you always end up with such a configuration.)

In your program, produce a random starting configuration and print it. Then keep applying the solitaire step and print the result. Stop when the solitaire final configuration is reached.

Use the following class as your main class:

import java.util.ArrayList;
import java.util.Random;

public class BulgarianSolitaire
{
private ArrayList piles;

/**
Sets up the game randomly with some number of piles of random
size. The pile sizes add up to 45.
*/
public void setupRandomly()
{
. . .
}

/**
This method can be used to set up a pile with a known (non-random)
configuration for testing.
@param pileSizes an array of numbers whose sum is 45
*/
public void setup(int[] pileSizes)
{
piles = new ArrayList();
for (int s : pileSizes)
piles.add(s);
}

public String getPiles()
{
return piles.toString();
}

/**
Play the game.
*/
public void play()
{
while (!isDone())
{
System.out.println(getPiles());
playRound();
}
System.out.println(getPiles());
}

/**
Play one round of the game.
*/
public void playRound()
{
. . .
}

/**
Checks whether the game is done.
@return true when the piles have size
1, 2, 3, 4, 5, 6, 7, 8, and 9, in some order.
*/
public boolean isDone()
{
. . .
}
}

Sample run:

13 4 6 6 10 6

6 12 3 5 5 9 5

7 5 11 2 4 4 8 4

8 6 4 10 1 3 3 7 3

9 7 5 3 9 2 2 6 2

9 8 6 4 2 8 1 1 5 1

10 8 7 5 3 1 7 4

8 9 7 6 4 2 6 3

8 7 8 6 5 3 1 5 2

9 7 6 7 5 4 2 4 1

9 8 6 5 6 4 3 1 3

9 8 7 5 4 5 3 2 2

9 8 7 6 4 3 4 2 1 1

……….

9 8 7 6 4 5 3 2 1

9 8 7 6 5 3 4 2 1

9 8 7 6 5 4 2 3 1

9 8 7 6 5 4 3 1 2

9 8 7 6 5 4 3 2 1

Number of iterations: 52

Answers

Answer:

note:

solution is attached in word form due to error in mathematical equation. furthermore i also attach Screenshot of solution in word due to different version of MS Office please find the attachment

g The machine in the problem has a byte-addressable memory of 216 bytes. The direct-mapped cache consists of 32 cache blocks, and the cache block size is 8 bytes. Question 1 How is the 16-bit memory address divided into byte offset, cache index, and tag? Question 2 What is the capacity of the cache in bytes? Question 3 Why tag is also stored in the cache? Question 4 For the following four memory addresses, what cache block would each be mapped to? 0001 0001 0001 1011 1100 0011 0011 0100 1101 0000 0001 1101 1010 1010 1010 1010

Answers

Final answer:

The 16-bit memory address is divided into 3 bits for byte offset, 5 bits for cache index, and 8 bits for tag. The direct-mapped cache has a capacity of 256 bytes. Tags in the cache help in verifying the data's integrity for proper retrieval, and the specific block each address maps to has been calculated based on the cache index.

Explanation:

Direct-Mapped Cache Addressing

To answer your questions regarding the direct-mapped cache and addressing, we must first divide the 16-bit memory address into three parts: byte offset, cache index, and tag.

Question 1: The memory address is divided as follows:

Byte offset (needed to select one byte from the 8-byte cache block): 3 bits

Cache index (to select one cache block from the 32 blocks): 5 bits

Tag (remaining bits after removing index and offset): 8 bits

Question 2: The capacity of the cache is the product of the number of cache blocks and the size of each block, which is 32 blocks × 8 bytes/block = 256 bytes.

Question 3: The tag is stored in the cache to identify which block of memory is currently stored in a cache line. It ensures the correct data is retrieved.

For the given memory addresses, the cache block they would be mapped to is as follows:

0001 0001 0001 1011 - Cache Block: 3

1100 0011 0011 0100 - Cache Block: 20

1101 0000 0001 1101 - Cache Block: 29

1010 1010 1010 1010 - Cache Block: 10

Note that we are using block numbers starting from 0.

When it comes to social media technologies and formal learning in the corporate environment, the only social media platform that can be used effectively for teaching and learning purposes is Twitter (Steer, 2015).

Answers

Ootions: TRUE OR FALSE

Answer: FALSE

Explanation: According to (Steer,2015) there are many platforms for learning and teaching purposes in corporate Organisations, they include PINTEREST,WIKI,GOOGLE+, LINKEDIN,TWITTER etc, The social media platforms are available for effective and efficient Communication and has been the main driving force for Businesses the world over.

These social media platforms have aided the growth and expansion of product marketing strategies and enhanced the over all business efficiency.

You are designing a write buffer between a write-through L1 cache and a write-back L2 cache. The L2 cache write data bus is 16 B wide and can perform a write to an independent cache address every 4 processor cycles.
a. How many bytes wide should each write buffer entry be?
b. What speedup could be expected in the steady state by using a merging write buffer instead of a non-merging buffer when zeroing memory by the execution of 64-bit stores if all other instructions could be issued in parallel with the stores and the blocks are present in the L2 cache?
c. What would be the effect of possible L1 misses on the number of required write buffer entries for systems with blocking and non-blocking caches?

Answers

Answer:

Clock 2.5GHz

L1 I cache 32KB, 8way, 64B line size, 4 cycle access latency

L1 Dcache write-back, write-allocate; MSHR with 0 (lockup

cache), 1, 2, and 64 (unconstrained non-blocking

cache) entries, write-back buffer with 16 entries

L2 cache 256KB, 8way, 64B line size, 10 cycle access latency

L3 cache 2MB per core, 64B line size, 36 cycle access latency

Memory DDR3-1600, 90 cycle access latency

Issue width 4

Instruction window size 36

ROB Size 128

Load Buffer Size 48

Store Buffer Size 32

b)

parallelism took this a step further by providing more parallelism and hence more

latency-hiding opportunities. It is likely that the use of instruction- and threadlevel

parallelism will be the primary tool to combat whatever memory delays are

encountered in modern multilevel cache systems.

that of the lockup cache setup (hit-under-0-miss). For the integer programs: the average performance

(measured as CPI) improvement is 7.08% for hit-under-1-miss, 8.36% for hit-under-2-misses, and 9.02%

for hit-under-64-misses (essentially the unconstraint non-blocking cache), compared to lockup cache. For

the floating point programs, the three numbers are 12.69%, 16.22%, and 17.76%, respectively

c)

Non-blocking caches are an effective technique for tolerating cache-miss latency. They can reduce

miss-induced processor stalls by buffering the misses and continuing to serve other independent access

requests. Previous research on the complexity and performance of non-blocking caches supporting

non-blocking loads showed they could achieve significant performance gains in comparison to blocking

caches. However, those experiments were performed with benchmarks that are now over a decade old.

Furthermore the processor that was simulated was a single-issue processor with unlimited run-ahead

capability, a perfect branch predictor, fixed 16-cycle memory latency, single-cycle latency for floating

point operations, and write-through and write-no-allocate caches. These assumptions are very different

from today's high performance out-of-order processors such as the Intel Nehalem. Thus, it is time to

re-evaluate the performance impact of non-blocking caches on practical out-of-order processors using

up-to-date benchmarks. In this study, we evaluate the impacts of non-blocking data caches using the latest

SPECCPU2006 benchmark suite on practical high performance out-of-order (OOO) processors.

Simulations show that a data cache that supports hit-under-2-misses can provide a 17.76% performance

gain for a typical high performance OOO processor running the SPECCPU 2006 benchmarks in

comparison to a similar machine with a blocking cache.

Explanation:

Write a Python function powerSet() that takes in a finite list object A and returns P(A), the power set of A. The output should be only in the form of list objects. Note: Make sure you are familiar with some of Python's basic built-in list functions and operators, as they will make completing this problem far easier. For example:

Answers

Answer:

#Code segment is written in Python Programming Language

#define Powerset(A)

def Powerset(A):

#Calculate length

Length = len(A)

#iterate through A

masks = [1 << count for count in range(A)]

for count in range(1 << Length):

yield [xy for mask, xy in zip(masks, A) if count & mask]

#Print Powerset

print(list(powerset([1,2,3])))

Explanation:

Line 1 defines the powerset

Line 2 calculates the length

Line 3 gets a range of the power set from 1 to the last

Line 4 checks if the iteration variable is still within range

Line 5 generates the Powerset

The essence of using the yield keyword is to ensure that one do not need to calculate all results in a single piece of memory.

Line 6 is to do the test code.

Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10}, print:

7 9 11 10
10 11 9 7

Hint: Use two for loops. Second loop starts with i = NUM_VALS - 1.


Note: These activities may test code with different test values. This activity will perform two tests, the first with a 4-element array (int courseGrades[4]), the second with a 2-element array (int courseGrades[2]). See How to Use zyBooks.

Also note: If the submitted code tries to access an invalid array element, such as courseGrades[9] for a 4-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message.

code:

import java.util.Scanner;

public class CourseGradePrinter {
public static void main (String [] args) {
final int NUM_VALS = 4;
int[] courseGrades = new int[NUM_VALS];
int i = 0;

courseGrades[0] = 7;
courseGrades[1] = 9;
courseGrades[2] = 11;
courseGrades[3] = 10;


return;
}
}

Answers

Answer:

Java code explained below

Explanation:

CourseGradePrinter.java

import java.util.Scanner;

public class CourseGradePrinter {

public static void main (String [] args) {

final int NUM_VALS = 4;

int[] courseGrades = new int[NUM_VALS];

int i = 0;

courseGrades[0] = 7;

courseGrades[1] = 9;

courseGrades[2] = 11;

courseGrades[3] = 10;

for(i=0; i<NUM_VALS; i++){

  System.out.print(courseGrades[i]+" ");

}

System.out.println();

for(i=NUM_VALS-1; i>=0; i--){

  System.out.print(courseGrades[i]+" ");

}

return;

}

}

Output:

7 9 11 10

10 11 9 7

Other Questions
a true breeding white mouse and a true breeding black mouse were crossed. All of their offspring were white. Which trait is dominant and which trait is recessive? Klingon Widgets, Inc., purchased new cloaking machinery three years ago for $5.0 million. The machinery can be sold to the Romulans today for $7.2 million. Klingons current balance sheet shows net fixed assets of $3.8 million, current liabilities of $810,000, and net working capital of $140,000. If all the current accounts were liquidated today, the company would receive $925,000 cash.What is the book value of Klingons total assets today?What is the sum of the NWC and market value of fixed assets? Find the perimeter of a rectangle with a base of 24mand a height of 36m. Describe the Virginia Plan and the New Jersey Plan. Identify which group preferred each plan and explain why. Write your response in four to five complete sentences( then theirs one more question after this) :) Read the excerpt from "A Journey West." Now, I was thirteen and I'd been working my whole life. I was the leader of the family (after Momma and Daddy, of course). Everyone knew I was a hard worker who handled a plow and team as well as any man. I could gentle a horse with a look and a whisper. So my family always listened to me. They all knew that Rosetta liked to make up drama whenever she could. The first-person point of view in this excerpt allows the reader to understand Rosetta's frustrations. Momma's concerns. Nate's feelings. Daddy's hopes. Describe how an individual becomes a certified medical assistant through the American association of medical assistants. It takes a resistance heater having 2 kW power to heat a room having 5 m X 5 m X 6 m size to heat from 0 to 33 oC at sea level. Calculate the amount of time needed for this heating to occur in min (Please take Patm=101 kPa, give your answer with three decimals, and do NOT enter units!!!). Read this paragraph from The Dark Game.It may seem surprising that no Confederate sympathizers took action against Van Lew, given her strong and public views on secession and slavery. Surely there were suspicions, especially among her upper-crust neighbors, but the matter never went beyond those suspicions. Historians have suggested that the secessionists were victims of their own cultural bias, believing that no aristocratic person, and certainly not a lady, would ever consider taking part in anything as impolite as spying. A true lady managed her servants, prepared parties and gatherings, and blindly supported her husband. Such attitudes worked in Van Lew's favor, diverting suspicion from her.What central idea is implied in this paragraph?1. Elizabeth Van Lew did not follow the rules society set forth for ladies of her time and social class.2. Elizabeth Van Lew was a successful spy because society did not expect a lady to serve in that role.3. Elizabeth Van Lew was able to disguise her spying activities because she kept her views about the war to herself.4. Elizabeth Van Lew created for herself an untrue but believable cover story: she was a wealthy lady living in a fancy neighborhood. Marionnette International is a worldwide operator and franchisor of hotels and related lodging facilities totaling nearly $1.6 billion in net property and equipment. Assume that Marionnette replaced furniture that had been used in the business for five years. The records of the company refilected the following regarding the sale of the existing furniture.Furniture (cost) $6,060,000Accumulated depreciation 5,551,000 Required: 1. Prepare the journal entry for the disposal of the furniture, assuming that it was sold for: (If no entry is required for a transaction/event, select "No journal entry required" in the first account field. Enter your answers in dollars not in millions.) a. $509,000 cash b.$1,619,000 cash c.$407,000 cash How did america convince panama to let them build a canal in their country? 2. Activities included (and not included) in the calculation of GDP The gross domestic product (GDP) of the United States is defined as the all in a given period of time. Based on this definition, indicate which of the following transactions will be included in (that is, directly increase) the GDP of the United States in 2020. Scenario 2020 GDP Included Excluded Treetopplers, a U.S. lumber company, produces wood at a plant in Oregon on September 13, 2020. It sells the wood to Buildit and Partners, a developer, for use in the production of a new house that will be built in the United States in 2020. (Note: Focus exclusively on whether production of the wood increases GDP directly, and ignore the effect of production of the new house on GDP.) Tasty's, a U.S. fast-food company, produces a hamburger at one of its many St. Louis locations on January 21, 2020. It sells the hamburger to a customer that same day. An accountant starts a client's 2020 tax return on April 14, 2021, finishing it just before midnight on April 15, 2021. Chocolate Express, a Swiss chocolate company, produces a chocolate bar at a plant in Illinois on December 5, 2020. An elementary school student buys the chocolate bar on December 24. Athleticus, a U.S. shoe company, produces a pair of sneakers at a plant in Vietnam on March 10, 2020. Athleticus imports the pair of sneakers into the United States on May 20, 2020. A carbon resistor is to be used as a thermometer. On a winter day when the temperature is 4.00 C, the resistance of the carbon resistor is 217.0 . What is the temperature on a spring day when the resistance is 215.1 ? Take the temperature coefficient of resistivity for carbon to be = 5.00104 C1 . The targets for anti-fungal drugs are much more limited than antibiotics or anti-viral medications. Why? What is the factored form of x6 - 9? What are the characteristic of financially responsible decision The __________ stage of the data science process helps in converting raw data to a machine-readable format. Rowanda could not settle her tax dispute with the IRS at the appeals conference. If she wants to litigate the issue but does not have sufficient funds to pay the proposed tax deficiency, Rowanda should litigate in the: Why do people in less developed countries use wood as a primary energy source? Help. Interpreting Graphs Of Proptional Relasionships. ! An inverted pyramid is being filled with water at a constant rate of 50 cubic centimeters per second. The pyramid, at the top, has the shape of a square with sides of length 8 cm, and the height is 15 cm. Find the rate at which the water level is rising when the water level is 3 cm.