1. File input.txt contains 100,000 numbers separated by new line. Do the following: 1.1 Write a C++ program to compute the summation of these 100,000 numbers using single thread. 1.2 Write a C++ program to compute the summation of these 100,000 numbers using 10 threads, meaning each thread compute 10,000 summations and the main thread sum the result of the 10 threads. 1.3 Using the time syscall to compare the time spent for 1.1 and 1.2 Source code of two programs and a short report on to answer the following question: 1. What is the run time for 1.1? 2. What is the run time for 1.2? 3. Is there a run time difference and why?
#include <pthread.h>
#include <iostream>
#include <cstdlib>
using namespace std;
// The adder thread that will add the number from 1 to n
void *adder(void * number);
// The sum variable that will be updated by all threads
unsigned long sum;
int main(int argc, char *argv[])
{
if (argc != 2) {
cerr << "Usage: sum <integer value>" << endl;
exit(1);
}
unsigned long number = atol(argv[1]);
if (number < 0) {
cerr << "Argument " << number << " must be non-negative." << endl;
exit(1);
}
pthread_t tid; // the thread identifierier
pthread_attr_t attr; // set of attributes for the thread
// get the default attributes
pthread_attr_init(&attr);
// create the thread
pthread_create(&tid,&attr,adder,(void *) number);
// Wait for the thread to exit
pthread_join(tid,NULL);
cout << "Sum(" << 1 << ", " << number << ") = " << sum << endl;
return 0;
}
1. File input.txt contains 100,000 numbers separated by new line. Do the following: 1.1 Write a...
File input.txt contains 100,000 numbers separated by new line. Do the following: Write a C++ program to compute the summation of these 100,000 numbers using single thread Write a C++ program to compute the summation of these 100,000 numbers using 10 threads, meaning each thread compute 10,000 summations and the main thread sum the result of the 10 threads. Using the time syscall to compare the time spent for 1.1 and 1.2 1.1 1.2 1.3 Turn Ins Source code of...
File input.txt contains 100,000 numbers separated by new line. Write a C++ program to compute the summation of these 100,000 numbers using 10 threads, meaning each thread compute 10,000 summations and the main thread sum the result of the 10 threads. Link to input: https://learn-us-east-1-prod-fleet01-xythos.s3.us-east-1.amazonaws.com/5b5739b6d55fd/3861301?response-content-disposition=inline%3B%20filename%2A%3DUTF-8%27%27input%25281%2529.txt&response-content-type=text%2Fplain&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190317T013820Z&X-Amz-SignedHeaders=host&X-Amz-Expires=21600&X-Amz-Credential=AKIAIBGJ7RCS23L3LEJQ%2F20190317%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=8b1d2221f602a9dcc7b39390663d957f4fdc29f13dcf0e31e5ec15f1566b1907
Write a Python program (question2.py) that reads from a file
called “input.txt” numbers in [1,39] separated in by commas. The
numbers are in [1-99]. The program will then convert each number to
a possible Roman Numeral equivalent, and print it on the screen.
Remember, I is 1, V is 5, X is 10
For example, if the input is: 23, 11 the output is: XXIII,
XI.
ROMAN NUMERALS CHART 1 TO 100 69 LXIX 11 2 11 3 III 4...
Here is the Prompt for problem 1:
Write a C++ program that reads in a test file. The first number
in the file will be an integer, and will indicate the amount of
decimal numbers to follow. Once you have the read the numbers from
the file into an array then compute the following properties on the
set of numbers: the sum, the average (mean), the variance, the
standard deviation, and the median. Don’t try to do the entire
program...
Do the following project: Following is the file to be programmed
in Linux kernel. Run this program. Include the screenshot of the
results.
Multi threaded Sorting Application
Write a multithreaded sorting program that works as follows: A
list of integers is divided into two smaller lists of equal size.
Two separate threads (which we will term sorting threads) sort each
sub list using a sorting algorithm of your choice. The two sub
lists are then merged by a third thread—a...
Question III This question carries 20% of the marks for this assignment. Given the following mix of tasks, task lengths and arrival times, compute the completion [5 marks and response time time from the arrival to the finish time) (5 marks for each task, along with the average response time for the FIFO. RR and SJF algorithms. Assume a time slice of 10 milliseconds and that all times are in milliseconds. You are kindly asked to provide the Gantt Chart...
Overview: In this lab, you will write a program called JobScheduler; it should take a single input file as a command-line argument. Each line in the input file has the following format: <job #> <priority> <arrival time (sec)> <duration (sec)> e.g. a file might contain: 1 3 10 100 5 2 20 50 8 4 5 100 (all values will be positive integers) These jobs might represent computer programs (or threads) that need to be run by the operating system....
Lab 1 Deliverable: Lab Report Please include the source code of each task in a separate.java file. Please add code in Lab 1.1 1.2, 1.3, 1.4 according to (https://crunchify.com/how-to-get-server-ip-address-and-hostname-in-java) to display your hostname and ip address. Please include screenshot of the result of each task in the lab report. Compress all source code and lab report into an zip file and submit your zip file with the name as student-first-name_student-number_labl.zip to Moodle before the class on June 3rd, 2020. Late...
in c
Q3) Write a program to generate three random numbers between 1 and 9 and display them. The user has to enter their sum as soon as possible. These two steps will be repeated continuously. An alarm will be triggered every 5 seconds to display the numb answers so far. If the user did not give a correct answer in 10 seconds, the timer will jump to the main to give an error message "Too slow response!" and terminate...
Need help with java programming. Here is what I need to do: Write a Java program that could help test programs that use text files. Your program will copy an input file to standard output, but whenever it sees a “$integer”, will replace that variable by a corresponding value in a 2ndfile, which will be called the “variable value file”. The requirements for the assignment: 1. The input and variable value file are both text files that will be specified in...