Mark Pearson
|
Single Threaded ResourceManager hangs system when killed/exited
|
Mark Pearson
08/18/2009 3:04 AM
post36135
|
Single Threaded ResourceManager hangs system when killed/exited
Hi,
I'm developing a driver which uses a single threaded resource manager. The device driver is interrupt driven, whose
interrupt service routine sends a pulse to an interrupt handler event, when an interrupt occurs.
Everything is working fine, until I wish to detach (kill, exit, etc) the driver.
When I kill the driver, the system hangs. This seems to be due to interrupts still coming for the device, but there is
no driver to handle them anymore.
In my initialisation of the driver, I've used "atexit" calls, which should cleanly detach all registered service,
interrupts and mask out the interrupts, but when I kill the driver, I don't see that these atexit functions are called.
I have written multi-threaded resource managers and utilised the atexit calls without any problems (and can kill off
those drivers without hanging the system). Unfortunately, I've inherited this single threaded code and can't change to
multi threaded.
Is there something I'm missing with a single threaded resource manager? Can I build in a signal handler to ensure clean
exiting of the driver?
The dispatcher loop, looks like this:
// Allocate a context structure
rinfo.ctp = dispatch_context_alloc(rinfo.dpp);
// Start the resource manager message loop
while(1)
{
if((rinfo.ctp = dispatch_block(rinfo.ctp)) == NULL)
{
fprintf(stderr, "block error\n");
exit(EXIT_FAILURE);
}
dispatch_handler(rinfo.ctp);
}
Any help would be greatly appreciated.
Many thanks in advance, Mark Pearson.
|
|
|