Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor manubemanu's Avatar
    Join Date
    Dec 2008
    Posts
    111
    Hi all
    I need a little help about multi thread programming.
    My application has two thread.
    1) Thread1 receive data from socket and fill a descriptor list
    2) Thread2 read single data from the list, elaborate it and then communicate to the view the data to be displayed. Then it goes on with the next data.

    MainThread: create the common list and start the ReadersThread. Then it appends on this list the data received from a bluetooth socket (100 packets per second!)
    ReadersThread: when something is available on the list, it elaborates it and it writes it on a file. Then it send data to the view.

    The problem is the classic readers and writers model. In other programming language, such as C#, I use events to wake up reader thread when the data is available on the list. what could be a solution in Symbian???



    Best regards
    Manuela

  2. #2
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    You should not use threads for that, active objects are exactly meant for this use case: practically they are meant to replace threads which would not do anything (=wait) in most of the time.

  3. #3
    Regular Contributor manubemanu's Avatar
    Join Date
    Dec 2008
    Posts
    111
    I have tried with active object.
    AOWriter
    AOReader
    but the elaboration of data need lot of time to be completed and so the list is increased too much and there is a big delay...


    Active object are on the same thread, right? so, even if the scheduler give to them a little time to work, they never work together on the same moment, I'm right? I need parallel computing...
    Last edited by manubemanu; 2010-09-03 at 12:04. Reason: Adding info

  4. #4
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    There is no such parallel computing in a single-core environment. Anyway, it is absolutely sure that the socket-stuff runs in no-time. If processing the data requires some time, move that part into a secondary thread.

  5. #5
    Nokia Developer Champion hotcheese's Avatar
    Join Date
    Jul 2004
    Posts
    2,015
    I don't want to presume on Wizard's behalf as he knows what he's talking about, but perhaps he meant to write, 'move that into a secondary active object', as you've already indicated you've moved over to AOs.

    In Symbian there is usually no need (for the vast majority of cases) to mix both active objects and threads. Threads "should" be used only when you *need* pre-emptive multi-tasking, if you don't then active objects should be used (which are not pre-emptive).
    Most people don't need pre-emptive multi tasking.

    "" - Of course you can use threads if you want to, but there's no need if its not necessary and as the whole SYmbian OS is designed around the use of active objects its more fitting to use them.

  6. #6
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    No, I really meant thread in this time. If Manubemanu does some intensive computation (mathematical - like signal processing), that could really go into a secondary thread.

  7. #7
    Nokia Developer Champion hotcheese's Avatar
    Join Date
    Jul 2004
    Posts
    2,015
    Hi, why do you recommend a secondary thread as opposed to a background AO?

    I know it could go into a thread, but I think mixing threads with AOs is best avoided if there's no need, keep things clean and simple.
    Last edited by hotcheese; 2010-09-07 at 17:54.

  8. #8
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    Ok, the 'if processing the data requires some time' might not be descriptive enough. However if Manubemanu receives some audio or video data via BT, and wants to do some complex maths with it (1/2D F/FT), that is easier to implement in a thread than unrolling the loop(s) in some active object.
    It will not be faster or slower (so it will not really help in deciding what should happen with additional inbound data), it is just going to be shorter. And yes, an active object is still necessary for getting the notification about the end of the calculation.

Similar Threads

  1. RSS readers
    By wpf in forum Mobile Web Site Development
    Replies: 0
    Last Post: 2007-12-19, 09:48
  2. We are looking for qualified and creative writers!
    By nicoleornelas in forum News, Announcements and Job Listings
    Replies: 0
    Last Post: 2007-05-15, 12:52
  3. Documentation writers should check MSDN Library
    By zdenko in forum Feedback - Nokia Developer Services
    Replies: 6
    Last Post: 2007-04-24, 17:34
  4. about resource readers
    By advocatee in forum Symbian C++
    Replies: 0
    Last Post: 2003-07-19, 11:43

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved