The Threaded OS Assignment
This assignment uses multiple threads to verify the Collatz Conjecture.
- Can verify the Collatz conjecture for all positive integers 1 ... 1,000,000
- Can print the number with the longest sequence.
- Have run it for 1 CPU, for 4 CPUs and for 16 CPUs, for 64 CPUs and for 256 CPUs. Tell me the run-time for each.
- Caches previous work.
- Has a queue of work, where each thread text the next work item.
You must use locking!
Due Thursday Sep 22. One half point per workday late
Here is the whole program written in Python.
def check(n):
if (n == 1): return 1
if (n % 2 == 0): return check(n//2)+1
else: return check(n*3+1)+1
max_so_far = 0
n_so_far = 0
for n in range(1,10000):
length = check(n)
if (length > max_so_far):
max_so_far = length
n_so_far = n
print("New Biggest", n, "has", length,"steps.")
print("N = ", n_so_far, "\tCount = ", max_so_far)