Docsity

Programming Assignment 1 Study Notes for Operating Systems | COP 6611, Assignments of Operating Systems

Toggle sidebar
bg1
USF Graduate Operating Systems, Spring 2008.
COP 6611: Programming Assignment 1
Objective: Experiment with differences between creating processes and creating threads in Linux.
Assignment (Due Monday, January 21): Write two programs in C that generate the Fibonacci sequence
of length n where n is (a natural number) given as input. In the first program, the sequence is generated in
a new process; in the second the sequence is generated in a new thread. Please look at Exercises 3.6 (page
117) and 4.11 (page 148) in your textbook for some relevant hints.
You are given a sample source code (fib.c) of a program that calculates the nth-Fibonacci number. You
are not required to use this sample code, if you prefer to write your own.
You are required to generate a set of experiments that investigate the difference in overhead between
threads and processes for the purpose of generating Fibonacci numbers. Ideas to try:
• The entire sequence is generated within one thread/new process.
• Multiple threads/processes are created and each generates a Fibonacci sequence. For example,
your programs might take two parameters: n and k, where n is as defined above and k is a small
positive integer (say, below 10). The programs will then create k processes/threads, where each
process i (between 0 and k-1) will compute the (n+i)th Fibonacci number. Please be aware of the
“fork bomb” and do not release it!!!!
The output should look something like this:
alagor@supernova:~/temp$ ./fib-fork 10 3
Answer: 55 /*fib 10 process/thread nr.1*/
Answer: 89 /*fib 11 process/thread nr.2*/
Answer: 144 /*fib 12 process/thread nr.3*/
To time your programs, you can use the time command or other available timing tools.
Deliverables:
1) A short write-up (1/2 page should be enough) presenting the timing results and a brief discussion
of the results. Your discussion should include:
a. What results you expected to see and why.
b. What experiments you ran to verify your expectations.
c. If your expectations were met; if not, why do you think this happened.
2) The source code.
This is an individual assignment. Your source code must compile on one of the C4 Lab PC’s
(c4labpc11.csee.usf.edu thru c4labpc29.csee.usf.edu). Although you can use any Linux environment to
write your programs, make sure you test your solution on one of these machines before submitting.

Partial preview of the text

Download Programming Assignment 1 Study Notes for Operating Systems | COP 6611 and more Assignments Operating Systems in PDF only on Docsity!

USF Graduate Operating Systems, Spring 2008.

COP 6611: Programming Assignment 1

Objective : Experiment with differences between creating processes and creating threads in Linux.

Assignment (Due Monday, January 21): Write two programs in C that generate the Fibonacci sequence of length n where n is (a natural number) given as input. In the first program, the sequence is generated in a new process; in the second the sequence is generated in a new thread. Please look at Exercises 3.6 (page

  1. and 4.11 (page 148) in your textbook for some relevant hints.

You are given a sample source code (fib.c) of a program that calculates the n th^ -Fibonacci number. You are not required to use this sample code, if you prefer to write your own.

You are required to generate a set of experiments that investigate the difference in overhead between threads and processes for the purpose of generating Fibonacci numbers. Ideas to try:

  • The entire sequence is generated within one thread/new process.
  • Multiple threads/processes are created and each generates a Fibonacci sequence. For example, your programs might take two parameters: n and k, where n is as defined above and k is a small positive integer (say, below 10). The programs will then create k processes/threads, where each process i (between 0 and k-1) will compute the (n+i)th Fibonacci number. Please be aware of the “fork bomb” and do not release it!!!!

The output should look something like this:

alagor@supernova:~/temp$ ./fib-fork 10 3 Answer: 55 /fib 10 process/thread nr.1/ Answer: 89 /fib 11 process/thread nr.2/ Answer: 144 /fib 12 process/thread nr.3/

To time your programs, you can use the time command or other available timing tools.

Deliverables:

  1. A short write-up (1/2 page should be enough) presenting the timing results and a brief discussion of the results. Your discussion should include: a. What results you expected to see and why. b. What experiments you ran to verify your expectations. c. If your expectations were met; if not, why do you think this happened.
  2. The source code.

This is an individual assignment. Your source code must compile on one of the C4 Lab PC’s (c4labpc11.csee.usf.edu thru c4labpc29.csee.usf.edu). Although you can use any Linux environment to write your programs, make sure you test your solution on one of these machines before submitting.