Question
File downloaders are programs used for downloading files from the Internet.here you will implement two different types of multi-process downloaders (i.e., file downloaders that comprise
File downloaders are programs used for downloading files from the Internet.here
you will implement two different types of multi-process downloaders (i.e., file downloaders that
comprise multiple processes):
1. a serial file downloader which downloads files one by one.
2. a parallel file downloader which downloads multiple files in parallel.
You will then compare the performance of the two types of downloaders.
Both downloaders will use the Linux wget program in order to perform the actual downloading.
The usage of the wget is simple: wget
the following command:
wget http://releases.ubuntu.com/15.04/ubuntu-15.04-desktop-amd64.iso
will download the Ubuntu Linux iso image to the current directory. Before proceeding with the
assignment, you may want to take a moment to experiment with the wget command.
In your program, the parent process shall first read the file, urls.txt, containing the URLs of the
files to be downloaded. urls.txt shall have the following format:
.
.
.
For example:
http://releases.ubuntu.com/cosmic/ubuntu-18.10-desktop-amd64.iso
http://releases.ubuntu.com/cosmic/ubuntu-18.10-live-server-amd64.iso
Next, the parent process shall fork the child processes. Each created child process shall use the
execlp() system call to replace its executable image with that of the wget program. The two types
downloaders are described in detail below.
The two downloaders shall be implemented as separate programs. The serial downloader
program shall be called serial.c (or .cpp extension if you use C++). The parallel downloader
program shall be called parallel.c (or .cpp extension if you use C++).
Serial Downloader
The serial downloader shall download files one by one. After the parent process has read and
parsed the urls.txt file, it shall proceed as follows:
1. The parent process forks off a child process.
2. The child uses execlp("/usr/bin/wget", "wget",
order to replace its program with wget program that will download the first file in urls.txt
(i.e. the file at URL
3. The parent executes a wait() system call until the child exits.
4. The parent forks off another child process which downloads the next file specified in
urls.txt.
5. Repeat the above steps until all files are downloaded.
Parallel Downloader
1. The parent forks off n children, where n is the number of URLs in urls.txt.
2. Each child executes execlp("/usr/bin/wget", "wget",
call where each
3. The parent calls wait() (n times in a row) and waits for all children to terminate.
4. The parent exits.
Performance Comparison
Use the time program to measure the execution time for the two downloaders. For example:
time ./serial
real 0m10.009s
user 0m0.008s
sys 0m0.000s
The column titled real gives the execution time in seconds. Please get the execution times for
both downloaders using the following urls.txt file:
http://releases.ubuntu.com/cosmic/ubuntu-18.10-desktop-amd64.iso
http://releases.ubuntu.com/cosmic/ubuntu-18.10-live-server-amd64.iso
Your execution times should be submitted along with your code.
In your submission, please include the answers to the following questions (you may need to do
some research):
1. In the output of time, what is the difference between real, user, and sys times?
2. Which is longer: user time or sys time? Use your knowledge to explain why.
3. When downloading the files above, which downloader finishes faster? Why do you think
that is?
4. Repeat the experiment for 10 files (any reasonably large-sized files, e.g., 100 MB, will
do). Is the downloader in the previous question still faster? If not so, why do you think
that is?
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