简体   繁体   English

使用RT Linux调度的多个TCP套接字

[英]Multiple TCP sockets using RT linux scheduling

If I use SCHED_FIFO and set the process priority to 1 how can I efficiently check when one of multiple tcp connections the process is managing has data available for processing? 如果我使用SCHED_FIFO并将进程优先级设置为1,如何有效检查进程正在管理的多个tcp连接之一何时有可用于处理的数据?

Ideally I want to multithread if multiple tcp sockets have data ready for processing. 理想情况下,如果多个TCP套接字具有可用于处理的数据,则我想使用多线程。

I think it would look something like an infinite loop checking each socket however it seems as if linux scheduler may have a solution. 我认为这看起来像是检查每个套接字的无限循环,但是似乎Linux Scheduler可能有解决方案。

Not sure how SCHED_FIFO effects your traditional server design. 不确定SCHED_FIFO如何影响您的传统服务器设计。 I mean the usage of listening socket and socket returned by accept. 我的意思是侦听套接字和accept返回的套接字的用法。 The idea is, main thread should blocked on the listening socket and when the new connection is received it should pass the fd returned by accept to new thread. 这个想法是,主线程应该在监听套接字上被阻塞,并且当接收到新的连接时,它应该将accept返回的fd传递给新线程。 New thread could be created for all new connections or you can have thread pool to limit it and for better control. 可以为所有新连接创建新线程,或者您可以具有线程池来限制它并更好地控制。

Other idea could be to use a thread which calls select on the fd's and main thread could listen and accept the connection, main thread can queue the new fd and send a notification(could be using signal or pipe) to thread which is waiting on select . 其他想法可能是使用在fd上调用select的线程,并且主线程可以侦听并接受连接,主线程可以将新的fd排队,并向正在等待select的线程发送通知(可以使用信号或管道) 。 once data is received it can use the worker thread from the thread pool to assign the task. 一旦接收到数据,它就可以使用线程池中的工作线程来分配任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM