Process Multiprogramming: 1. Write a program to execute a for loop causing time
ID: 3672687 • Letter: P
Question
Process Multiprogramming:
1. Write a program to execute a for loop causing time to elapse. Use any language you'd like. Measure the time the program takes to execute and display the results (design your program to take approximately 15 seconds to execute).
2. Write a script to execute twenty (20) instances of the program. Start the processes sequentially and note their process IDs.
3. Write the elapsed time results to a file using the pipe (|) command within the script and concatenate the results into a single file listing the PID and the elapsed time to completion in two columns.
4. Run the script multiple times to observe that the first process does not necessarily always complete first or with with the same elapsed time.
5. Modify the script to assign a nice level of high to the first of the twenty processes. Leave all other processes at the default nice value. Observe that the prioritized process now completes more quickly than the others.
6. Modify your program to loop forever. Execute a script that starts twenty (20) processes that will loop forever. Use the top command to view the executing processes, their memory utilization and their CPU utilization. Kill all of the processes using the kill system call.
Explanation / Answer
If you run that code, you'll leak threads. Make sure to clean up the timer when you've finished
3)
4)yes the first process does not necessarily always complete first or with the same elapsed time.
6)
public class InfiniteForLoop {
public static void main(String[] args) {
/*
* Its perfectely legal to skip any of the 3 parts of the for loop.
* Below given for loop will run infinite times.
*/
for(;;)
System.out.println("Hello");
/*
* To terminate this program press ctrl + c in the console.
*/
}
}
2)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.