--- src/driver.c.orig 2008-01-27 05:30:34.000000000 +0100 +++ src/driver.c 2008-01-27 05:30:34.000000000 +0100 @@ -111,7 +111,10 @@ static DECLARE_WAIT_QUEUE_HEAD(wait); static DECLARE_WAIT_QUEUE_HEAD(capi_wait); +static DECLARE_COMPLETION(thread_sync); /* New DECLARE, */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) static DECLARE_MUTEX_LOCKED(hotplug); +#endif #define SCHED_WAKEUP_CAPI { atomic_set (&thread_capi_flag, 1); wake_up_interruptible (&capi_wait); } #define SCHED_WAKEUP { atomic_set (&got_kicked, 1); wake_up_interruptible (&wait); } @@ -1367,7 +1371,10 @@ } } LOG("Scheduler thread stopped.\n"); + complete(&thread_sync); /* Complete Thread Sync here */ + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) up (&hotplug); + #endif return 0; } /* sched_thread */ @@ -1401,7 +1410,10 @@ SCHED_WAKEUP; } LOG("Thread signalled, waiting for termination...\n"); + wait_for_completion(&thread_sync); /* Wait for complete Thread Sync */ + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) down (&hotplug); + #endif LOG("Thread[%d] terminated.\n", thread_pid); } thread_pid = -1;