Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Help On Perl - Multi Threading

by koti688 (Sexton)
on Feb 24, 2009 at 09:22 UTC ( #745946=perlquestion: print w/replies, xml ) Need Help??

koti688 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Mates

i need suggetions / help on this problem.

we are doing a online Backup/ Restore Diaster recovery Solution.
For that till now , we have implemented Synchronous Data Transfer model for both Backup and restore.

i was involved in Testharness of these Back end operations.

Now the devlopment is moving to Asynchrous Datatransfer mode. So i need to test in asynchronous mode for backup and restore.

i am using Perl for this Testharness. So to proceed with Asynchrous mode of Testing, need to Implement Multi threading in Perl.

Can you please tell me on how to proceed with this, i dont have much knowledge on Perl Multi threading.

Replies are listed 'Best First'.
Re: Help On Perl - Multi Threading
by BrowserUk (Patriarch) on Feb 24, 2009 at 12:12 UTC

    There are many ways to use threads. Which is approriate for your particular application will depend upon what that application is. Unless you describe your application, all you will get is meaningless handwaving answers. It is impractical for anyone to describe all the ways they can be used so that you can pick the appropriate one. Besides, you almost certainly wouldn't be equipped to make that decision up front.

    I see from one of your previous questions that you've already read the nearly useless perlthrtut and are still none the wiser. (Don't feel bad, very few will ever learn anything useful from that document.)

    If you are seriously pursuing help with creating a multitasking solution to your problem, then you will need to describe that problem in some detail, and explain what you are hoping to achieve by multitasking it.

    One last piece of advice: Write a non-multitasking version first. Once you have a working, single tasking solution, it will be far easier to explore multitasking and: a) verify that the addition of multitasking isn't causing incorreect results; b) get a feel for whether you are actually benefiting from the extra complexity involved.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Are there any documents you would recommend in place of perlthrtut ?

        None that I have seen.

        perlthrtut is little more that a verbose expansion of the threads pod. More reference than tutorial. All how and no why.

        Imagine someone asking the question: "I want to bake a pie".

        You could tell them about making pastry. You might mention the difference between savoury and sweet pastry. You could attempt to cover the need for a light touch and the affect of hand temperature upon pastry texture. You might mention blind baking. You might list some cooking temperature/time guidelines. You could talk about wet and dry fillings; and the need vent steam; and soggy crusts.

        But unless you start out by asking them the type of pie they are wanting to bake; the kind of filling they envisage; and how many people they are hoping to serve; most all of that advice is just going to set them up for disappointment.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
        You might learn something from an article I wrote about using Perl threads in little toy app:

        http://www.perl.com/lpt/a/667

        Personally I prefer to use fork and pipes for IPC when I'm doing parallel programming with Perl. Perl's threads are too slow and the problems using non-thread-safe XS modules are too painful.

        -sam

      Hello BU

      Thanks for the Explanation.

      i will abstarct out my project here.

      SuperVault is a complete backup restore and disaster recovery solution. The solution is being implemented as a client server environment where in the client is the front end which is known as back up engine and the server is the back end which is made of a scalable distributed data storage system.


      I deal with Test Harness of this product.Test Harness (TH) is a suite of tools (That is Customized)that helps us to perform functionality and performance testing on Super Vault solution. The suite helps the user to perform the following activities.

      1) Creating test cases
      2) Managing test cases
      3) Managing test case collections
      4) Executing test case collections
      5) Generating test execution reports

      Till now ,We are doing synchronous data transfer for sending and receiving acknowledgments for each block being sent.

      But We need to have buffered asynchronous mode data transfer from now onwards.
        But We need to have buffered asynchronous mode data transfer from now onwards.

        Everthing you wrote prior to that line was 'sales pitch'. It tells us nothing about what help you need.

        • But We need to have: Why? What are you hoping to gain?
        • buffered: Buffered where? (At the client; at the server; both?) Buffered why? (To reduce communications bandwidth? To coalesce adjacent transmissions?
        • asynchronous mode: "mode"?
        • asynchronous ... data transfer: Why? What are you hoping to achieve?
          • Increase throughput?
          • Reduce server latency?
          • Improve client responses?
          • Speed up your testing cycles?
          • Saturation test your servers without requiring dozens of physical test clients?
          • Allow you to add the "asynchronous" keyword to your adverts so as to stack up better against your commercial rivals?
          • Avoid having to employ more testers?

        Unless you can answer the questions above without asking your manager or mentor, you are probably the wrong person to be tackling the project.

        And is that from now onwards, the now when you posted; or the now when I read it? :)

        On a more serious note. If you are under pressure to try and complete this by some prescribed deadline, despite that you do not yet have a good idea how you are going to so, then you should seriously consider taking the project back to your management and telling them to ...


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Help On Perl - Multi Threading
by gone2015 (Deacon) on Feb 24, 2009 at 09:43 UTC

    Well you need to start with: perlthrtut.

    If you've already read that, and you're still stuck, then ask further...

Re: Help On Perl - Multi Threading
by zentara (Archbishop) on Feb 24, 2009 at 11:54 UTC
    To give you a quick overview, threads are used when you need to share data/progress/signals between threads in REAL time. If each thread/process can run independently of the others, use fork instead. The details of why this is so, is in the docs and tutorials. Threading in Perl presents some unusual problems, that are not present in c pthreads.

    I'm not really a human, but I play one on earth My Petition to the Great Cosmic Conciousness
Re: Help On Perl - Multi Threading
by zentara (Archbishop) on Feb 24, 2009 at 20:26 UTC
    If you want a better thread introduction, google for "perl threads tutorial". There are all sorts of introductions to threads to get you going. Also, searching groups.google.com for "perl threads" will yield many example programs, explaining all the pitfalls to watch out for. The tutorial section here at Perlmonks also has some nice articles, just search the tutorial page for "thread"

    I'm not really a human, but I play one on earth My Petition to the Great Cosmic Conciousness
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://745946]
Approved by rovf
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2022-06-27 20:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (88 votes). Check out past polls.

    Notices?