chengkai15 commented on PR #22268:
URL: https://github.com/apache/nuttx/pull/22268#issuecomment-7135043419

   apache/nuttx-apps#4129 depends on this PR.
   
   zblue (merged in apache/nuttx-apps#3977) creates its Zephyr work queues with 
`work_queue_create()`. In the flat build the workers are kernel threads, while 
the HCI receive thread and the application threads are pthreads of the 
application, so the host is split over two task groups. On current master this 
makes `bt_enable()` hang on sim:zblue:
   
   - The thread-specific key of the zblue porting layer is created by the first 
work queue, so it belongs to the kernel thread group. Since 0bc013bb2b, 
`pthread_setspecific()` returns `EINVAL` in the application's receive thread. 
That thread then keeps the cooperative lock while it blocks in `read()`, and 
the host TX work queue waits on that lock forever, so HCI_Reset is never sent.
   - File descriptors are not shared either, which is why zblue needed a 
separate TX work queue that opens `/dev/ttyHCI0` a second time.
   
   apache/nuttx-apps#4129 switches zblue to `work_queue_create_pthread()`, 
removes that TX work queue, and writes in `send()` again. With this PR and 
#4129 on master, sim:zblue with a CSR controller passes discovery, MTU 
exchange, write, 200 reads on one connection, and 10 reads on new connections. 
All host threads are pthreads of the application. #4129 stays in draft until 
this PR is merged.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to