RE: clean AudioServerDriver plugin unload
RE: clean AudioServerDriver plugin unload
- Subject: RE: clean AudioServerDriver plugin unload
- From: Bertrand Van Kempen <email@hidden>
- Date: Wed, 08 Jan 2014 12:23:46 +0100
- Thread-topic: clean AudioServerDriver plugin unload
Thanks a lot for all those explanations; you make me progressing in the Apple development world.
Bertrand
-----Original Message-----
From: coreaudio-api-bounces+bvankempen=email@hidden [mailto:coreaudio-api-bounces+bvankempen=email@hidden] On Behalf Of Jeff Moore
Sent: Tuesday, January 07, 2014 7:00 PM
To: Core Audio Mailing List
Subject: Re: clean AudioServerDriver plugin unload
It isn’t just an interesting point of view. It is SOP for our operating system.
If a driver has state to clean up that depends on hooking the exit of the hosting process, the driver is implemented incorrectly. The hosting process can always crash and such a driver would lose data which is very bad behavior indeed.
The proper thing to do is for the driver to save any persistent state as soon as it needs to as you seem to have realized independently. In addition to protected data from crashes, it serves the purpose of speeding up process exit as there isn’t lot of work to do at process exit time doing pointless things like freeing memory or closing connections to drivers or what have you.
—
Jeff Moore
Core Audio
Apple
On Jan 7, 2014, at 6:03 AM, Bertrand Van Kempen <email@hidden> wrote:
> Hi Jeff,
>
> Hum, it is an interesting point of view which implies that the process knows that all its sub modules don't need to save their settings at clean up time or doing special tasks e.g mute physical output (I suppose that you assume that this task should be done by a driver (kext))
>
> Anyway, my plugin saves its settings each times they are changed so it could die at any time.
>
> Bertrand
>
> -----Original Message-----
> From: coreaudio-api-bounces+bvankempen=email@hidden [mailto:coreaudio-api-bounces+bvankempen=email@hidden] On Behalf Of Jeff Moore
> Sent: Monday, January 06, 2014 7:21 PM
> To: Core Audio Mailing List
> Subject: Re: clean AudioServerDriver plugin unload
>
> In general, it is a bad practice to do clean up work when a process is about to die. The only thing it accomplishes is to prevent the process from exiting quickly.
>
> The reason why is that the kernel reclaims all the resources the process was using once the process has been torn down. So there is generally no point in freeing memory or closing connections, etc. The kernel will handle that as part of reclaiming the process’s resources.
>
> This is why coreaudiod doesn’t do anything special when it is unloaded. It just dies as quickly as it can. The most obvious place this shows up is at reboot time. Any time coreaudiod spends spinning around waiting for the driver to clean itself up at process exit slows down the whole rebooting procedure.
>
>
> —
>
> Jeff Moore
> Core Audio
> Apple
>
>
> On Jan 6, 2014, at 6:36 AM, Bertrand Van Kempen <email@hidden> wrote:
>
>> Hello Jeff,
>>
>> Happy New Years 2014!
>>
>> To check if my plugin hasn't memory leaks, I would like to unload it in a cleaner way than kill coreaudiod.
>>
>> I noticed that the plugin is not destroyed properly when coreaudiod is killed; the plugin just disapear.
>>
>> In that way, the plugin cannot properly destroy all its objects and stop the kext associated.
>>
>> Is there absolutely no way to ask coreaudiod to exit properly?
>>
>> How OSX does at shutdown?
>>
>>
>>
>> Best regards,
>>
>> Bertrand
>>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden