I'm going to go with shoot the guy with the knife until he quits trying to get up or you run our of bullets, then deal with your knife wounds and call 911 for your knife wounds, hoping you don't die from your knife wounds because there are going to be knife wounds.
A more perfect response might be to try to circle away while drawing and firing, but based on my limited level of competency, I think shooting the hell out of the guy would be a good first step for me.
Good luck getting your gun out in that situation. This is what force on force is about people. We as well as others take this stuff and run it in dynamic scenarios to see what works, or at least what keeps you alive. You don't want the first time something like this happens to you to be for real. Our 0-5 ft pistol gunfighting deals almost exclusively with these type of situations. A gun may come into play, but only after you have either wrapped him up, created distance, or flanked him. I have seen these types of attacks in prison, and even been on the recieving end. It is not pretty, even less so if you haven't prepared. Just watching a video on it is not being prepared.