Posix Thread Programming

This is a discussion on Posix Thread Programming within the C Programming forums, part of the General Programming Boards category; Write a Multithreaded parallel programs in Pthread package to solve Laplace's Equation over a two dimensional n*n grid using Gauss-Seidel ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    5

    Posix Thread Programming

    Write a Multithreaded parallel programs in Pthread package to solve Laplace's Equation over a two dimensional n*n grid using Gauss-Seidel and Red-Black relaxation methods,respectively.
    Assume the grid is initialized to zeroes and its external boundary points along the four edges are initialized to 10.0 , 5.0 , 10.0 and 5.0.
    Assume the iteration stops when the differences between the iteration values are less than 0.01.
    Assume the number of threads is p.For simplicity,you may assume p divides n evenly.
    You may use any assignment approach.
    Last edited by Salem; 10-14-2004 at 01:15 AM. Reason: Font and colour abuse

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,163
    And....?

    Did I miss something? Did someone sign me up for a class and I've just met my instructor?
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    52
    First of all how about you delete one of your threads because u posted this in both c++ and c boards. Second of all, itsme is right, what on earth are u talking about....?

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Here is the code

    Code:
    #include <pthread.h>
    
    void* ask_others(void *read_post)
    {
      int *other_people = (int*)read_post;
      int completed_assignment = do_homework();
      return &completed_assignment;
    }
    
    int main()
    {
      int messageboard_post;
      void *completed_homework;
      pthread_t th;
      pthread_create(th,0,ask_others,(void*)&messageboard_post);
      relax();
      have_fun();
      wait_for_homework();
      pthread_join(th,&completed_homework);
    
      turn_in_homework(completed_homework);
    
      return 0;
    }
    As you can see, all you have to do is start a new thread where people view your messageboard post. This worker thread essentially does your homework for you. While this thread is working, you call your relax() and have_fun() methods. Finally your worker thread finishes, and you get a pointer to the completed_homework. All that's left to do is call the turn_in_homework() function, passing it the completed_homework reference you got from the worker thread.

    Let me know if you have any more questions.

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,662
    I have tears in my eyes.....

    I'd give some to bithub but I gotta spread it around first

    gg

  6. #6
    Registered User
    Join Date
    Sep 2004
    Posts
    5
    Quote Originally Posted by bithub
    Here is the code

    Code:
    #include <pthread.h>
    
    void* ask_others(void *read_post)
    {
      int *other_people = (int*)read_post;
      int completed_assignment = do_homework();
      return &completed_assignment;
    }
    
    int main()
    {
      int messageboard_post;
      void *completed_homework;
      pthread_t th;
      pthread_create(th,0,ask_others,(void*)&messageboard_post);
      relax();
      have_fun();
      wait_for_homework();
      pthread_join(th,&completed_homework);
    
      turn_in_homework(completed_homework);
    
      return 0;
    }
    As you can see, all you have to do is start a new thread where people view your messageboard post. This worker thread essentially does your homework for you. While this thread is working, you call your relax() and have_fun() methods. Finally your worker thread finishes, and you get a pointer to the completed_homework. All that's left to do is call the turn_in_homework() function, passing it the completed_homework reference you got from the worker thread.

    Let me know if you have any more questions.




    H i,

    Thank you for your reply .
    But u got me wrong.
    I am working hard on this topic.can you atleast gimme some more overview on the post i did ????

  7. #7
    Registered User
    Join Date
    Oct 2004
    Posts
    120
    Hahahaha, that hard work is really showing...keep at it!

  8. #8
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,163
    Show us the code you've got so far and ask specific questions. All we've seen is your assignment and a message from you saying you're working hard on it. Forgive us for being skeptical...
    If you understand what you're doing, you're not learning anything.

  9. #9
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    I'm am posting this because it appears that you are posting a homework assignment or other project and you are asking for someone else to do all of the work.

    Please don't ask people to do all your work for you, See the announcement on Homework at the top of the forum to see what is acceptable or PM me.

    Basically people are happy to help, but they're not going to do it all for you.

    Show us what you've got, show your code (using code tags), or where you're confused and someone will be happy to help you I'm sure. If it's something that you absolutely don't understand how it works, like you have no clue how qsort works, then ask a general question about the function and I'm sure someone will explain it. Though they may not give you all of the code for it, but someone will explain the concept.

    On obivous homework questions especially, I also like to remind people of the board's tenth guildeline, while this board is very helpful to people, make sure you have your instructor's permission before seeking help on assignments. While people on these boards are more than happy to help, we discourage people from asking for help on graded work without the instructor's permission, and we claim no repsonsibilty for any cheating or honor violations.

    Feel free to PM me with any questions.

    Good Luck,

    Kermi3
    Lead Moderator
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multithreading (flag stopping a thread, ring buffer) volatile
    By ShwangShwing in forum C Programming
    Replies: 3
    Last Post: 05-19-2009, 07:27 AM
  2. Replies: 2
    Last Post: 02-26-2009, 10:48 PM
  3. Replies: 2
    Last Post: 07-01-2007, 07:11 AM
  4. Messaging Between Threads, Exiting Thread On Demand, Etc.
    By HyperShadow in forum C++ Programming
    Replies: 10
    Last Post: 06-09-2007, 01:04 PM
  5. Multi-Thread Programming
    By drdroid in forum C++ Programming
    Replies: 6
    Last Post: 04-04-2002, 01:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21