Multi-processes programming - multithread programming and


Learning Objectives

The learning objectives of this assignment are to apply the knowledge in the course including multi-processes programming, multithread programming, communication of processes and process synchronization to solve a complex problem which involves multiple sides working together. This assignment requires the design, development, testing, and debugging skills of C language.

Specifications

Four external processes will communicate temperatures to a central process, which in turn will reply with its own temperature and will indicate whether the entire system has stabilized. Each process will receive its initial temperature upon creation and will recalculate a new temperature according to two formulas:

new external temp = (10*myTemp + centralTemp) / 11;

new central temp = (centralTemp + 1000* temp sum of external processes) / (1000*number of external processes + 1);

Initially, each external process will send its temperature to the central process through mailbox. If all external temperatures are exactly the same as that of the central process, the system has stabilized. In this case, the central process will notify each external process that it is now finished (along with the central process itself), and each process will output the final stabilized temperature. If the system has not yet become stable, the central process will send its new temperature to each of the external processes through mailbox and await their replies.

The processes will continue to run until the temperature has stabilized. The C programs of the external and central are given in Appendix (note don't remove instruction usleep(100000) in all tasks in this assignment). Compile and run as follows

#./external 10 1 &
#./external 100 2 &
#./external 1000 3 &
#./external 10000 4 &
#./central 10 &

Task-1. Simple Extension

Write central8.c and external8.c to perform the same task as described by the specifications where 8 external processes are considered. Compile and run as follows:

#./external8 10 1 &
#./external8 100 2 &
#./external8 1000 3 &
#./external8 10000 4 &
#./external8 50 5 &
#./external8 500 6 &
#./external8 5000 7 &
#./external8 50000 8 &
#./central8 10&

Task-2. Serve Two Group

Now consider there are two groups of external processes where the first group has external process 1-4 and the second group has external process 5-8. Each group of external processes communicate with the central to perform the same task as described by the specifications. The central process is with a single thread of control. For the first and second group, the initial temperature in the central is 10 and 100 respectively. Write central44.c and external44.c. Compile and run as follows (record the central process running time):

#./external44 10 1 1200 &
#./external44 100 2 1200 &
#./external44 1000 3 1200 &
#./external44 10000 4 1200 &
#./external44 50 5 1300 &
#./external44 500 6 1300 &
#./external44 5000 7 1300 &
#./external44 50000 8 1300 &
#./central44 10 100 1200 1300 &

Task-3. Multithread Programming

Perform the same task as described in Task-2 but the central process is with two threads of control. Each thread is corresponding to one group of external processes. Write central442T.c and external442T.c. Compile and run as follows (record the central process running time):

#./external442T 10 1 &
#./external442T 100 2 &
#./external442T 1000 3 &
#./external442T 10000 4 &
#./external442T 50 5 &
#./external442T 500 6 &
#./external442T 5000 7 &
#./external442T 50000 8 &
#./central442T 10 100 1200 1300 &

Assignment Report

The report should include a cover page to indicate the course title, course code, semester information, assignment #, assignment total marks, your lab time, your lab assistant name, your name, your student identity. The body of the report includes

1. Introduction

It should include a brief introduction of the assignment, the brief description of the system, the summary of what you have done in this assignment and the most important experience/lessons learned.

2. Assignment Tasks

2.1. Task - 1

The summary of your solution (including what you have done in central and external); Self-reflection and/or lessons learned; Report the converged temperature; Report the execution time of central; Report the demonstration date.

2.2. Task - 2

The summary of your solution (including what you have done in central and external); Self-reflection and/or lessons learned; Report the converged temperature for two groups respectively; Report the execution time of central process; Report the demonstration date.

2.3. Task - 3

The summary of your solution (including what you have done in central and external); Self-reflection and/or lessons learned; Report the converged temperature for two groups respectively; Report the execution time of central process; Report the demonstration date.

3. Analysis

3.1. Multithread Efficiency

Compare and contrast task-2 and task-3 in terms of execution time of central process. Provide explanation to your observation.

3.2. Synchronization

Analyse whether task-3 requires semaphore for process synchronization or not in your code, and explain your decision.

Solution Preview :

Prepared by a verified Expert
Operating System: Multi-processes programming - multithread programming and
Reference No:- TGS01112222

Now Priced at $200 (50% Discount)

Recommended (90%)

Rated (4.3/5)