Re: Threading and Synchronization in Mass storage driver
site_archiver@lists.apple.com Delivered-To: Darwin-kernel@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=uIDVgATCTK+30Cb3nU0RHq1Hw7QKAteuJTFiJu2nGDJF+j/B01p74WNrQNwjmbj8Y5WxCdNZsKG/6i0s9MrwUkrP0eU9quMhiYNpdET6k9hWfX3t9W6CbGFJ7L/t86Q/LYomtOUBmIDaOvUpRdbjazO51q56r2qdB1ABAHNy1SQ= On 12/16/05, Herb Petschauer <bogvardi@gmail.com> 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 <pahilwan.yogesh@spsoftindia.com> 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 (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
Herb Petschauer