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.

about NDK socket

Other Parts Discussed in Thread: SYSBIOS

Dear all, 

        I know the socket function  ,recvncfrom(), is a blocking IO function without assigning the timeout value for the socket . 

        I would like to know Is that possible to wake up the pending task by a nother task ? 

        The sudo code like below . 

5751.test.c

    

  • Brenden,

    I don’t think that what you show in the pseudo code will work.  Task_a() will block waiting on the I/O to complete.  Task_b() posts a semaphore, but where is that defined?  And how would Task_a() be pending on it, specifically to cause early termination of the I/O?  

    Scott

  • Sorry for  misunderstanding , please forget the semaphore , let me explain my request   precisely !

    My real request is that task A and B need to send the udp packet  both from  certain source port to certain destination port (ex 623 to 55421).

    But in Ndk software architecture, it is impossible for two tasks  to use single socket  sending packet . 

    So , I need use another way to implement  the function . Such as Using  task A to do the sending packet job , and task B just store the packet in mailbox , then task A can check mailbox to sending packet while  socket timeout . But this way have an side effect , cpu overload to heavy while  socket timeout is small. 

    So we need a solution to replace socket timeout method . if using the linux , then we can use the inter socket to send data to Task A , So task A can remain blocking IO.

    But how we do these kind of function by using sysbios+ndk?? any idea ? 

    Regards,

    Brenden

  • Hi Brenden,

    Actually you can share a socket between tasks.  You need to use the fdShare() API.

    Please refer to the following threads which cover this topic:

    http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/t/230192.aspx

    and

    http://e2e.ti.com/support/embedded/bios/f/355/p/120158/429219.aspx#429219

    Steve