How to block an API call without blocking server message loop?

Valery V. Sedletski _valerius at mail.ru
Sat Apr 2 01:58:34 CEST 2011


Hi all.

When an L4 server is started, its main thread goes into the server loop and blocks until a message 
from a client is received. When a message is received, a server loop calls a dispatch function, 
which calls functions, specific to RPC opcodes. The problem is that if one of these functions is 
blocked, the whole server loop is blocked.

In my case, I am implementing an API, which is called by a client program. This API starts a child 
process, and has an option to block the calling program, until the child is terminated. This API is 
called DosExecPgm(). So, the client program calls this API, then the API call blocks, and then the 
child must be executed, and finally, call another API, which is called DosExit(). But when 
DosExecPgm is called, the server loop is blocked, and it cannot receive a message for calling 
the next API, DosExit.

I tried to implement API call blocking using a semaphore. DosExecPgm from a parent process is 
waiting on the semaphore, and DosExit from a child process reset the semaphore.

So, the problem is with server loop blocking. So, I thought to make for DosExecPgm a dedicated 
server loop. which is blocked, but the main server loop continues to execute. But how to correctly 
make these server loops? There are many API's which can block, so, what can I do if not to 
dedicate a separate loop for each function? And, if there are many server loops, then there will be 
many threads executing them, so I must to register each thread on the name server. -- Then how 
can the calling program determine, which server thread to call for each API?

I feel that these problems have common solutions, but i'm in trouble -- maybe, someone will help 
with finding these common solutions?

Thanks in advance,
WBR,
valery






More information about the l4-hackers mailing list