Write a non-threaded program to simulation heat dissipation

Assignment Help Operating System
Reference no: EM131296003

Threads 

Thanks to Dr. Clemens Grelck at the University of Amsterdam for these excellent concurrent programming assignments:

Problem A: Sieve of Eratosthenes

Implement a multithreaded version of the Sieve of Eratosthenes. The Sieve of Eratosthenes is an ancient algorithm to compute prime numbers, attributed to the Greek mathematician Eratosthenes of Cyrene (276 BC - 194 BC). You can read and view an animation of the Sieve here: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes.

Here's an outline of a multithreaded version of the Sieve of Eratosthenes:
- the main thread generates an unbounded sequence of natural numbers starting at 2
- the main thread generates a SINGLE filter thread for the natural number 2 and then sends all subsequent numbers (3 to N) this filter thread via a SafeQueue data structure
- any number that is not a multiple of 2 is discarded by this filter thread
- any other number is a potential prime, so this filter thread passes the number onto the NEXT filter thread for processing, in this case the next filter thread will be for the prime number 3
- there will be a filter thread for each prime number that your Sieve uncovers so there's a filter thread for 2, 3, 5, 7, etc...
- when a new prime number is encountered, a filter thread is created for the prime number and it is connected to the previous filter thread via the SafeQueue data structure
- the first time a filter thread is created it will display the prime number that it is filtering
- the user specifies the NUMBER of prime numbers desired on the command line when executing the main program and the program terminates once that number of primes has been discovered

897_Q.png

Problem B: Scientific Simulation

Write a non-threaded program to simulation heat dissipation on the surface of a cylinder. You can model a cylinder using a 2D HxC array of cells. H represents the height of the cylinder and C represents the circumference of the cylinder (position cylinder[x][0] is adjacent to position [x][C-1]).

Each cell has a temperature (a double) that is initialized to tinit.

Select N cells at random (hard code the number of cells and their locations for testing) and set these cells to temperatures that are higher or lower than tinit. The temperature can be different for each of these cells (use the same temperature for testing). The temperature at each of these cells will remain FIXED for the duration of the simulation.

For each iteration of the simulation the temperature of each cell is recomputed as the weighted average of:
- the previous iteration's temperature (X) using weighted coefficient C0
- the previous iteration temperatures of the 4 direct neighbor cells (N0, N1, N2, N3) using weighted coefficient C1
- the previous iteration's temperature of the 4 diagonal neighbor cells (D0, D1, D2, D3) using weighted coefficient C2

2048_Figure.jpg

NOTE: There are three boundary conditions to consider:
- cylinder[x][0] and cylinder[x][C-1]
- cylinder[0][y] (no D0, N0, D1 available for weighted average)
- cylinder[H-1][y] (no D2, N3, D3 available for weighted average)

The simulation is complete when:
- max iterations have passed OR
- the simulation has converged on delta.

Convergence means that the difference between the previous iteration's cell temperature and the recomputed cell temperature is less than or equal to delta for all cells in the cylinder.

At the end of the simulation print out:
- the cylinder cells
- the maximum delta across the cells
- the average temperature across the cells
- the program execution time (actual cpu time used by the program not wall clock time)
- an estimate of the number of floating point operations per second (FLOPS)

To facilitate experiments, the simulator should accept H, C, tinit, c0, c1, c2, delta, max as command line arguments.

Report the output of running your program with these values in a file results.txt:
- H = C = 10, 100, 1000 (meaning 3 separate runs with 10x10, 100x100, 1000x1000)
- tinit=20C
- c0 = 0.5, c1=.1, c2=.025
- put a 40C heat source @ H/2,C/2
- put a 0C heat source @ H/4,C/4
- put a 0C heat source @ H-3, C-3
- experiment with delta and max

Here are some sample runs of the program:

main

10 10 20 .5 .1 .025 .001 10000

main

100 100 20 .5 .1 .025 .001 10000

main

1000 1000 20 .5 .1 .025 .001 10000

(H=10 or 100 or 1000, C=10 or 100 or 1000, tinit=20, c0=.5, c1=.1, c2=.025, delta=.001, max=1000)

Problem C: Scientific Simulation II

Parallelize your program for the simulation of heat dissipation on the surface of a cylinder developed in Problem B using threads by adding the number of threads to be used to the list of command line arguments... assume the user won't ask you for more than 100 threads.

There are a wide range of design choices in the parallelization of your code and you should experiment with them. You to strive for "fast" code that aims at keeping the overhead from multithreaded execution small. For example, avoid repeated creation and termination of threads and have an eye on balancing the workload reasonably among the cooperating threads.

Some hints for implementation:
- Keep the threading solutions simple to avoid race conditions and synchronization problems.
- Compare the running time of your solution to problem B with your solution to problem C. Which solution takes less time and why?

Here is a sample run of the program that uses a max of 50 threads:

main 10 10 20 .5 .1 .025 .001 10000 50

Please use semaphores in the manner

Reference no: EM131296003

Questions Cloud

What can you do to protect iis : What can you do to protect IIS? What can you do to protect other web servers like Apache or Tomcat as well?
Discuss with examples the connection between nursing process : NUR 563: Advanced Nursing Service Administration- As a nurse manager; how can you create a work environment in which the necessary elements and requirements for the main components of the FIRM process can be met?
Assignment-data mining : Use the following link to perform the Data Mining tutorial in SQL Server Data Tools (SSDT) for SQL Server 2014: https://technet.microsoft.com/en-us/library/ms167167(v=sql.120).aspx.
Develop a slide presentation for your information systems : Use your findings from the previous individual assignments to develop a slide presentation for your information systems security implementation recommendation. The recommendation should identify risks, threats, and vulnerabilities.
Write a non-threaded program to simulation heat dissipation : CSC314 Operating Systems - Write a non-threaded program to simulation heat dissipation on the surface of a cylinder. You can model a cylinder using a 2D HxC array of cells - Implement a multithreaded version of the Sieve of Eratosthenes.
Enterprise-wide knowledge management systems : Identify a web link to an existing technology for each of the following categories and provide a description of each system you found that includes an explanation or example of what it does:
Draw the two possible intermediates of the given reaction : Draw the two possible intermediates of the reaction shown. Draw the complete structures of all of the possible products that are formed from these intermediates.
Quantitative approaches superior : Describe at least three ways to identify and categorize project risks. In your view, are quantitative approaches superior? Why or why not? Describe the steps that you would follow when developing a communications plan among project participants. O..
Technical experiences that you used in completing lab : Submit the .vls file you create in Visual Logic as well as a screenshot of the output. For full credit, the program must function correctly, produce the correct answer, and be logically succinct.

Reviews

Write a Review

Operating System Questions & Answers

  A computer has a cache, main memory, and a disk

A computer has a cache, main memory, and a disk. If a referenced word is in the cache, 20 ns are required to access it. If it is in main memory but not in the cache (called cache miss)

  Explain in the difference between testing and debugging

Which activity is more time consuming and why?

  Explain the sorting algorithm

Throughout the statement and solution to this problem, a caret ("^") denotes that the number immediately following it is an exponent.

  How can operating system keep track of which pages are clean

Assuming that each page has hardware bits to separately enable access for reading, writing, and execution, how can the operating system keep track of which pages are clean and which are dirty?

  Discuss the differences between windows and mac os

Discuss the differences between Windows and Mac OS. You may discuss any recent versions of either operating system. Compare and contrast the two, and provide arguments for choosing a PC with Windows or a Mac with Mac OS.

  Problem on demand-page system

Describe in general how the system is being used and explain the effect on the above measurement (CPU utilization) if the following occurred

  Operating system proposal

Operating System Proposal

  1 whenever a thread references a part of the virtual

1 whenever a thread references a part of the virtual address space that is not currently loaded in the primary memory

  Question about security policy

ABC Corporation is a small but growing manufacturing corporation with revenues of approximately $25 million. Until now, the corporation has had a single headquarters and production facility in a Midwestern city,

  Creating pseudocode

Create pseudocode for the Citron Car rental policy, Standard transmission is available only for A, B, and C. Automatic transmission is available for all cars.

  Issues with trusted platform modulewrite a research paper

issues with trusted platform modulewrite a research paper discussing the issues with trusted platform module tpm. your

  Describe carefully what changes are made in directory system

Suppose that the UNIX system call unlink(¢¢/usr/ast/bin/game3¢¢) were executed in the context. Describe carefully what changes are made in the directory system.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd