This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

dm648 Thread scheduling

I'm using the send() interface in the NDK lib , I'd like to know when to send data whether occupy CPU.If the data quantity is larger, whether in NDK repository to send several times. when call the JPEG encoder interface whether occupy CPU. If I have two threads, a thread is network transmission data, a thread is JPEG compression, the same priority.Whether they can parallel operation.

  • Hi xue han,

    I'm not sure I quite understand what your actual problem is, but I'll do my best...

    xue han said:
    I'd like to know when to send data whether occupy CPU

    Are you asking if the call to send() uses the CPU?  The answer to this is yes.  The NDK itself doesn't use any DMA.

    xue han said:
    If the data quantity is larger, whether in NDK repository to send several times.

    send() should send all of the data for you and return the number of bytes transferred.

    It internally contains a loop that keeps calling a protocol dependent function to send (e.g. for TCP or UDP depending on your socket type).  The loop handles the limitations of the underlying protoI if the data passed to it is larger than what will fit into a packet.  For example, if you are sending TCP data, each packet is limited to 1460 bytes (for Ethernet packets).  So it would have multiple calls to the TCP send function, filling up a packet with 1460 bytes of data until all of the data has been processed.

    Are you seeing a scenario in which send() is not sending everything you expected?

    xue han said:
    If I have two threads, a thread is network transmission data, a thread is JPEG compression, the same priority.Whether they can parallel operation.

    You may want to experiment with priorities, but my guess is that the JPEG compression thread should be higher priority and your network thread lower and it can send once you have a bunch of compressed data ready.  Again, this is just a guess as I don't really know what your trying to do.

    Steve

  • Hi Steve,

              Thank you very much for your apply.Sorry, the finally  problem is not expressed clearly, so I have to trouble you again answer for me.


    There are two threads. A thread per 70 ms execution time, mainly for the JPEG compression, spend time is about 60 ms. Thread B mainly for network transmission, spend time is about 15 ms. How do I design to make thread B and A thread takes the total time is less than 70 ms. I hope they can parallel operation. I think thread B data in the network stack to the PHY for DMA work, do not take up CPU, but actual results are not so.

  • xue han,

    xue han said:
    How do I design to make thread B and A thread takes the total time is less than 70 ms.

    The DPS is only one core and so can only work on one given thing at any instance of time.  It does not support parallel processing. 

    How dependent on each other are threads A and B?  Do you have to send all of the data in task B?  Can you send less data in task B to shorten the total time spent in each thread?

    Also, is there any way to make your code in task A/B more efficient?

    xue han said:
    I think thread B data in the network stack to the PHY for DMA work, do not take up CPU, but actual results are not so.

    Are you using EDMA and you're not seeing it working?  Do you need help with the EDMA setup?

    Steve