[okl4-developer] Using OKLinux to provide services
Damien Schulz
damien.schulz at 4xtc.de
Wed Aug 6 19:59:36 EST 2008
Hi Geoffrey,
the pagefault happens in the function dequeue_task of the Linux kernel. Any idea what could cause this problem?
01f09110 <dequeue_task>:
1f09110: e1a0c00d mov ip, sp
1f09114: e92dd830 stmdb sp!, {r4, r5, fp, ip, lr, pc}
1f09118: e2804020 add r4, r0, #32 ; 0x20
1f0911c: e24cb004 sub fp, ip, #4 ; 0x4
1f09120: e3a02601 mov r2, #1048576 ; 0x100000
1f09124: e2822c01 add r2, r2, #256 ; 0x100
1f09128: e2815004 add r5, r1, #4 ; 0x4
1f0912c: e5913000 ldr r3, [r1] <-- crash
1f09130: e2433001 sub r3, r3, #1 ; 0x1
1f09134: e5813000 str r3, [r1]
Thank you!
~Damien
--- glee at ok-labs.com wrote:
From: Geoffrey Lee <glee at ok-labs.com>
To: Damien Schulz <damien.schulz at 4xtc.de>
Cc: developer at okl4.org
Subject: Re: [okl4-developer] Using OKLinux to provide services
Date: Wed, 6 Aug 2008 14:23:44 +1000
On Tue, Aug 05, 2008 at 07:51:58AM -0700, Damien Schulz wrote:
> 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:
>
To debug this, you need to break into the debugger to find out which
thread is causing the pagefault, then disassemble the relevant program
to see what it was doing at that point in time.
-gl
> 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
>
> _______________________________________________
> Developer mailing list
> Developer at okl4.org
> https://lists.okl4.org/mailman/listinfo/developer
>
--
More information about the Developer
mailing list