nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

problem(please help)

This is a discussion on problem(please help) within the Coding in General forums, part of the Development/Scripting category; hi there.. well im new in unix world however i like it and i feel im good on it anyway ...


Go Back   nixCraft Linux Forum > Development/Scripting > Coding in General

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 04-06-2007, 11:28 PM
Junior Member
 
Join Date: Apr 2007
Posts: 1
Rep Power: 0
alex18
Default problem(please help)

hi there..
well im new in unix world however i like it and i feel im good on it
anyway i am stuck in a problem and try to solve it but i need some help
its about multithreading
please help me and make me one of your member family
please as soon as possible
thnx
{{
Write a C language program to implement multithreaded matrix multiplication using Pthreads

• Create a separate worker thread to compute each row of the result matrix, instead of a thread for each element.
• Do not initialize the contents of the A and B matrices statically. The A and B matrices will be initialized by reading data from an input file (see notes below).
• Be able to process multiple sets of input matrices by continuing to read data in the specified format (described below) until you encounter an input line containing a single hash mark (‘#’) instead of an integer value for M (first dimension of the A matrix). If any other character than a hash mark is specified, output an error message and terminate the program with a non-zero return code. Each set of data processed must be labeled to indicate which set of data is being output (e.g., Set 1, Set 2, etc).

The input file will be an ASCII file containing numbers that define the dimensions and contents of the A and B matrices for which a matrix product is to be computed. The first line of the input file will contain two numbers specifying the dimensions of the A matrix (M x K). Following that will be M lines, each with K numbers, representing the elements of matrix A. Next will be a line with two numbers specifying the dimensions of the B matrix (K x N). And following that will be K lines, each with N numbers, representing the elements of matrix B. For example, suppose that matrix A has 2 rows and 3 columns and matrix B has 3 rows and 4 columns, as follows:
A B
1 2 3 3 5 7 9
4 5 6 8 6 4 2
4 3 2 1
The lines in the input file would be as follows:
2 3
1 2 3
4 5 6
3 4
3 5 7 9
8 6 4 2
4 3 2 1
program should print the contents of matrix A and matrix B. It should then print lines showing the thread ID numbers for the worker threads it creates. Then it should

print the contents of the result matrix C. The output from program for the above input should look similar to the following:
Set 1 Matrix A:
1 2 3
4 5 6
Set 1 Matrix B:
3 5 7 9
8 6 4 2
4 3 2 1
Created worker thread 15823744 for row 0
Created worker thread 26375040 for row 1
Set 1 Matrix C = A x B:
31 26 21 16
76 68 60 52

matrices will have a most 10 rows and 10 columns

Notes:
• Thread ID value is actually an address of an opaque thread data structure that is implementation dependent on each OS version . To get to the actual thread number would make program non-portable! That is, the actual Id number is saved in different places in the data structure on different systems

• you must create at least two threads, running at the same time, before you will see a different address (Thread ID) listed
}}
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-05-2007, 06:05 AM
wje_nc's Avatar
Junior Member
User
 
Join Date: Nov 2007
Location: Mariposa
My distro: Slackware 9.1
Posts: 3
Rep Power: 0
wje_nc is on a distinguished road
Default

Since this is obviously a homework assignment, you would do well to post the code you have so far so we can comment on it.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +5.5. The time now is 05:41 AM.


Powered by vBulletin® Version 3.7.2 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36