can you please answer me 1 and 2 ? A system with two dual-core processors has fo
ID: 3791932 • Letter: C
Question
can you please answer me 1 and 2 ?
A system with two dual-core processors has four processors available for scheduling. A CPU-intensive application (e.g., a program that spends most of its time on computation, not I/O or memory accesses) is running on this system. All input is performed at program start-up, when a single file must be opened and read sequentially. Similarly, all output is performed just before the program terminates, when the program results must be written sequentially to a single file. Between startup and termination, the program is entirely CPU'-bound (e.g., only executing instructions). Your task is to improve the performance of this application by multithreading it. Specifically, you must determine: How many threads will you create to handle input and output? Briefly explain. How many threads will you create for the CPU-bound portion of the application? Briefly explain. Consider the code segment below. The thread creates () function starts a new thread in the calling process (For the purpose of this problem, you can ignore the lack of arguments to that function.) How many unique processes arc created? How many unique threads are created? pid_t pid; pid - fork() if (pid - 0)//Child process fork (); thread create(. ..); fork();Explanation / Answer
1. (a) Only one thread each. Both input and out have to written sequentially. So, introducing multiple threads will create a race condition, and would require complex interprocess communication.
1. (b) 4 threads.
Reason: After the input file has been read, the file contents can be divided into 4 parts and each part can be assigned to a thread which can process it independently. After processing has been completed, all threads can dump their outputs which can be picked up easily by the output creation thread.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.