[okl4-developer] Using OKLinux to provide services
Damien Schulz
damien.schulz at 4xtc.de
Wed Aug 6 00:51:58 EST 2008
Hi there,
currently I'm implementing a service on top of OKLinux that communicates via IPC with other OKLinux instances (clients). An example how to access OKL4 services from OKLinux is already provided in the wiki pages but not how to provide services in OKLinux.
The service itself is provided by a user-mode program that reads from a procfs file. The read operation is blocked using a mutex until an IPC has been received by the server thread (in kernel mode).
But I always get the following page fault:
waiting for lock...
<...>
server: Received IPC ( from = 108001, label = 12 ).
server: producer 1 -- end
Unhandled page fault:
addr=0x0/??? priv=R
ip=0x1e0912c, sp=1efe6ac
pd=0x00127240 thread=0xfc001
Has anyone an idea would could cause this page fault and how I can avoid it. I'm using OKL4 1.5.2. Below you will find the modifications to the OKLinux kernel:
main.c:
int main(int argc, char **argv) {
<...>
thread_create(&ipc_thread);
r = L4_Set_Priority(ipc_thread, 98);
L4_KDB_SetThreadName(ipc_thread, "L_ipc");
<...>
L4_Start_SpIp(ipc_thread, (L4_Word_t) &ipc_stack[STACK_SIZE-1], (L4_Word_t) ipc_loop);
<...>
}
ipc_loop.c:
unsigned long xchg_data;
struct semaphore PC1_w, PC1_r, PC1_m, PC2_w, PC2_r, PC2_m;
void ipc_loop(void) {
L4_MsgTag_t tag;
L4_ThreadId_t from;
L4_Msg_t msg;
init_MUTEX(&PC1_w);
init_MUTEX(&PC1_r);
down(&PC1_r);
init_MUTEX(&PC1_m);
/* producer 1 begin */
down(&PC1_w);
down(&PC1_m);
printk("server: waiting for incoming messages...\n");
while ( 1 ) {
tag = L4_Wait( &from );
while ( L4_IpcSucceeded( tag ) ) {
unsigned int label = L4_Label( tag );
printk( "server: received IPC ( from = %lx, label = %lx ).\n", (unsigned int)from.raw, label );
xchg_data = label;
/* producer 1 end */
up(&PC1_m);
up(&PC1_r);
printk( "server: producer 1 -- end\n" );
/* consumer 2 begin */
down(&PC2_r);
down(&PC2_m);
<...>
procfs_module.c:
extern unsigned long xchg_data;
extern struct semaphore PC1_w, PC1_r, PC1_m, PC2_w, PC2_r, PC2_m;
static int __init proc_init(void) {
init_MUTEX(&PC2_w);
init_MUTEX(&PC2_r);
down(&PC2_r);
init_MUTEX(&PC2_m);
<...>
static int proc_server_wait_ipc( char *buf, char **start, off_t offset, int size, int *eof, void *data) {
printk( "waiting for lock...\n" );
/* consumer 1 begin */
down(&PC1_r);
down(&PC1_m);
printk( "recvd = %08x\n", xchg_data );
*((unsigned int*)buf) = xchg_data;
/* consumer 1 end */
up(&PC1_m);
up(&PC1_w);
/* producer 2 begin */
down(&PC2_w);
down(&PC2_m);
*eof = 1;
return 4;
}
Thank you!
~Damien
More information about the Developer
mailing list