Skip to main content
GameDev.net gamedev.net
🔒 Locked

Process Running Off a USB. USB Removed Momentarily

Started by daveyn Apr 7, 2008 at 11:09 PM 5 replies 1k views
Original Post
daveyn
daveyn
Hello All, I am currently working on a project looking into the plausibility of running our application off of a USB Flash Drive. The application itself consists of many .exes that communicate with each other via ports that are opened as needed and also many .dlls that are loaded up as required during the process lifespan. The problem that I am looking into at the moment is when if a user removes the usb from their machine (thereby losing the location of all the .exes and .dlls) and then plugs it back in again, can the application still run normally. Note that if the user removes the usb from the machine the application pauses and is blocked with a modal dialog. No interaction with the application can be made until the USB Flash Drive has been plugged back in and USB Flash Drive is valid. At first thought I didn't think that I would run into too many problems as I assumed any .exes and .dlls that are being used would be loaded into memory completely. However my knowledge into the total scheme into how windows handles the loading of .exes and .dlls into memory is lacking. Does anyone have any thoughts or just some general information onto how windows many handle the loading of .dlls and .exes into memory and to how windows may behave when this event occurs (i.e the Removal of the USB Device). Thanks in advance and feel free to pose any questions.
iMalc
iMalc
I think the problem is that if people are unplugging a USB flash drive that is in use then they need to be educated as to their proper use.
It's just like switching your computer off at the wall when you're done, without shutting down the PC, or even closing any apps. Sooner or later you'll likely get some nasty corruption.

As they say, trying to make something idiot-proof is a losing battle as the world simply produces bigger idiots. (or something to that effect)
daveyn
daveyn
Quote:
Original post by iMalc
I think the problem is that if people are unplugging a USB flash drive that is in use then they need to be educated as to their proper use.
It's just like switching your computer off at the wall when you're done, without shutting down the PC, or even closing any apps. Sooner or later you'll likely get some nasty corruption.

As they say, trying to make something idiot-proof is a losing battle as the world simply produces bigger idiots. (or something to that effect)


Dont worry hehe.. I completely agree. The "Bossman" wants me to still look at it though although I have mentioned many times that I don't think its a good idea as unforeseen problems could manifest themselves in places that work fine on one occasion but not another. I mean what if you unplug your hard-drive from your computer while Windows is running etc.... you wouldn't expect it to keep working would you. I'm more just doing some research and development to see whats possible to give some reasonable facts into why its not a good idea/it wont happen.

I just figured Id post to see if there were any ideas floating around that I hadn't thought of.
Kylotan
Kylotan
Quote:
Original post by daveyn
At first thought I didn't think that I would run into too many problems as I assumed any .exes and .dlls that are being used would be loaded into memory completely. However my knowledge into the total scheme into how windows handles the loading of .exes and .dlls into memory is lacking.


It does something like locking them on the disk and treats that as virtual read only memory. In other words, it's the opposite of what you expected/hoped. I am not sure what would happen if you removed the stick during execution - maybe nothing, if it's all shadowed in RAM already. Or maybe it would blue-screen. Try it and see...

Extrarius
Extrarius
If you're using Microsoft Visual C++, I believe what you're looking for is the /SWAPRUN linker option.

Ordinarily, executables are memory-mapped in read-only mode, which means the OS will happily discard the pages whenever the working set gets too large, with no way to get them back if the media has been removed.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
daveyn
daveyn
Kylotan, Extrarius - Thanks for the replies.

I will have a look at the swaprun linker option today and see what happens.
daveyn
daveyn
Thanks Guys.. the /SWAPRUN option worked great. Still got a few other issues to work out but they are related to the code itself (handling of messaging between .exes etc).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.