Issues about server multi-threading on L4Re

Jakub Jermar jakub.jermar at kernkonzept.com
Fri Sep 21 16:26:12 CEST 2018


Hi there!

On 09/21/2018 02:10 PM, 李 鼎基 wrote:
> I’m trying to implement some multi-threading IPC benchmarks on L4Re.
> Following the /“shared_ds”**/demo, firstly, I create 8 threads to send
> IPC on client and receive them all on server’s main thread.
> 
> The server loops, waits for the requests and handles them in the
> “dispatch” function. This single-thread server works well.
> 
>  
> 
> Then I want to create 8 threads in server (so that it can serve the
> client thread-to-thread).
> 
> I wrap the “server.loop();” in a “thread_fn” and use “pthread_create” to
> create more threads, however, the server will get stuck.
> 
> There are some printings after entering thread_fn so that I can make
> sure new threads are created and executed except the server.loop part.

I guess the problem is in that you are trying to use the same server
loop for all your threads. The server loop is associated with a single
server thread that executes the server objects. In other words, all but
the thread which is associated with your server loop just block there
and don't receive any IPC calls.

> In order to serve different requests concurrently, is there any way to
> create a multi-threading server?

In theory (never tried that myself), you can try giving a separate
server loop to each of your threads. You will then need to register your
server object at each of them. The end result should be that your client
threads are each connected to a different IPC gate which has its own
bound server thread. All of these gates carry the label of the same
server object which will be invoked when an IPC call arrives at any of them.

HTH,
Jakub

-- 
Kernkonzept GmbH at Dresden, Germany, HRB 31129, CEO Dr.-Ing. Michael
Hohmuth




More information about the l4-hackers mailing list