Re: Threading and Synchronization in Mass storage driver
Re: Threading and Synchronization in Mass storage driver
- Subject: Re: Threading and Synchronization in Mass storage driver
- From: Herb Petschauer <email@hidden>
- Date: Fri, 23 Dec 2005 19:09:16 -0800
On 12/16/05, Herb Petschauer <email@hidden> wrote:
> Your panic begins at:
>
> /Users/yogeshp/PROJECTS/SnapShot/DarwinCode/xnu-517.7.21/iokit/Kernel/IOLib.c:140
>
> -H.
>
>
> On 16 Dec 2005 19:19:35 +0530, Yogesh P <email@hidden> wrote:
> > Hi Herb,
> >
> > I have setup a 2 machine debugging to trace out the exact cause of the
> > crash while using the IOLockSleep() synchronization primitive.
> >
> > During 2 machine debugging, I have found that the threads get created
> > successfully but when the call goes to IOLockSleep(request_lock, (void*)
> > thread_id, false)the driver gets crashed.
> >
> > I put the stack backtrace for the same crash as follows:
> >
> > gdb()
> > Breakpoint 1, com_CoreSnap_driver::init(OSDictionary*) (this=0x1c7be20,
> > properties=0x1d74a60) at Spsoft_CoreSnapDriver.cpp:64
> > 64 IOLog("\n Inside Init function...\n");
> > (gdb) n
> > Current language: auto; currently c++
> > Line number 65438 out of range; Spsoft_CoreSnapDriver.cpp has 1568
> > lines.
> > (gdb) n
> > Breakpoint 1, com_CoreSnap_driver::init(OSDictionary*) (this=0x1b110a0,
> > properties=0x1d74880) at Spsoft_CoreSnapDriver.cpp:64
> > 64 IOLog("\n Inside Init function...\n");
> > (gdb) n
> > Line number 65438 out of range; Spsoft_CoreSnapDriver.cpp has 1568
> > lines.
> > gdb) n
> > 78 for(i = 0; i < NUM_HANDLER_THREADS; i++)
> > (gdb) n
> > 80 thr_id[i] = i;
> > (gdb) n
> > 82 IOLog("\nInit():: thr_id = %d\n", thr_id[i]);
> > (gdb) n
> > Line number 65438 out of range; Spsoft_CoreSnapDriver.cpp has 1568
> > lines.
> > (gdb) n
> > 84 IOThread thread_t =
> > IOCreateThread(com_CoreSnap_driver::handle_request_loop, (void*)
> > &thr_id[i]);
> > (gdb) n
> > 86 if(thread_t)
> > (gdb) n
> > 88 IOLog("\nInit():: Thread created successfully\n");
> > (gdb) n
> > Line number 65438 out of range; Spsoft_CoreSnapDriver.cpp has 1568
> > lines.
> > (gdb) n
> > Program received signal SIGTRAP, Trace/breakpoint trap.
> > Debugger (message=0x2d4440 "panic") at
> > /Users/yogeshp/PROJECTS/SnapShot/DarwinCode/xnu-517.7.21/osfmk/ppc/model_dep.c:627
> > 627 TRAP_DEBUGGER;
> > (gdb) bt
> > #0 Debugger (message=0x2d4440 "panic") at
> > /Users/yogeshp/PROJECTS/SnapShot/DarwinCode/xnu-517.7.21/osfmk/ppc/model_dep.c:627
> > #1 0x00034d84 in panic (str=0x2d43c8 "{%d} Assertion failed: file
> > \"%s\", line %d: %s\n") at
> > /Users/yogeshp/PROJECTS/SnapShot/DarwinCode/xnu-517.7.21/osfmk/kern/debug.c:198
> > #2 0x0004201c in assert_wait (event=0x0, interruptible=0) at
> > /Users/yogeshp/PROJECTS/SnapShot/DarwinCode/xnu-517.7.21/osfmk/kern/sched_prim.c:619
> > #3 0x00042424 in thread_sleep_mutex (event=0x1927d98, mutex=0x0,
> > interruptible=1) at
> > /Users/yogeshp/PROJECTS/SnapShot/DarwinCode/xnu-517.7.21/osfmk/kern/sched_prim.c:749
> > #4 0x20e65530 in com_CoreSnap_driver::handle_request_loop(void*)
> > (data=0xcb63cb4) at
> > /System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOLocks.h:112
> > #5 0x002777d4 in ioThreadStart () at
> > /Users/yogeshp/PROJECTS/SnapShot/DarwinCode/xnu-517.7.21/iokit/Kernel/IOLib.c:140
> > Current language: auto; currently c
> > (gdb) n
> > 635 splx(spl);
> > (gdb) n
> > 637 }
> > (gdb) n
> > panic (str=0x2d43c8 "{%d} Assertion failed: file \"%s\", line %d: %s\n")
> > at
> > /Users/yogeshp/PROJECTS/SnapShot/DarwinCode/xnu-517.7.21/osfmk/kern/debug.c:202
> > 202 PANIC_LOCK();
> > (gdb) n
> > 204 PANIC_UNLOCK();
> > (gdb) n
> > 203 panicstr = (char *)0;
> > (gdb) n
> > 204 PANIC_UNLOCK();
> > (gdb) n
> > 205 thread->wait_queue = save_waits[cpu_number()]; /*
> > Restore the wait queue */
> > (gdb) n
> > 206 if (return_on_panic) {
> > (gdb) n
> > 205 thread->wait_queue = save_waits[cpu_number()]; /*
> > Restore the wait queue */
> > (gdb) n
> > 206 if (return_on_panic) {
> > (gdb) n
> > 211 kdb_printf("panic: We are hanging here...\n");
> > (gdb) n
> > 212 while(1);
> > (gdb) n
> >
> > Please suggest so that I can pinpoint the issue.
> >
> > Thanks in advance,
> > Yogesh Pahilwan
And back to bottom posting...
Ok, I downloaded the xnu-517.7.21 source (aka OS X, 10.3.5), and I
opened IOLib.c and guess which line is line 140?
static void ioThreadStart( void )
{
IOThreadFunc fcn;
void * arg;
fcn = threadArgFcn;
arg = threadArgArg;
lock_done( threadArgLock);
(*fcn)(arg);
IOExitThread();
}
Hint: (*fcn)(arg);
So, if you haven't modified the kernel source and built your own
custom kernel I'm wondering if your kernel threads are actually
working. Try scaling back to your threading code unit test and see if
your threads are indeed being created correctly.
But I would really recommend you read Cliff and Mike's comments in
this thread as they are more valid (i.e. it looks a lot like you are
trying to re-invent the wheel, poorly). Read up on the IOCommandPool,
IOWorkLoop at the very minimum. Please!
Cheers,
H.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden