Jump to content
  • Advertisement
Sign in to follow this  
Nicholas Kong

Why do games pause the game while saving the game?

This topic is 2138 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does it have anything to do with hazards taught from a Computer Architecture class? Like Data Hazards?

 

I notice this a long time ago in all games especially in all 2D games but never questioned why it was implemented this way until now.

Edited by warnexus

Share this post


Link to post
Share on other sites
Advertisement

All depends on design, many games have auto save features that run while you are playing. Most of the time when you hit a save button it is in a screen where the game would be paused anyways so it would not make sense to resume it.

Share this post


Link to post
Share on other sites

When a game is saving it has to write the data to the hard drive or other data storage medium. This is a relatively slow process, so in a single threaded game it must wait until this process is finished before the game resumes.

Share this post


Link to post
Share on other sites

^yes also what Ludus said. At times it can be a long process especially for a single threaded application. Again it all depends on design. Many games do save during gameplay. Some even warn you and tell you to not turn off your console while an HDD access indicator is turned on.

Share this post


Link to post
Share on other sites

^yes also what Ludus said. At times it can be a long process especially for a single threaded application. Again it all depends on design. Many games do save during gameplay. Some even warn you and tell you to not turn off your console while an HDD access indicator is turned on.

Ah so writing to the hard drive is a slow process? Why is that? Is writing to the hard drive exhausting resources(memory from CPU and RAM)?

When you pause a game, does it make the Game do less work then? 

Share this post


Link to post
Share on other sites

Ah so writing to the hard drive is a slow process? Why is that? Is writing to the hard drive exhausting resources(memory from CPU and RAM)?
When you pause a game, does it make the Game do less work then?


The API and OS will buffer writes for you, but eventually those buffers will be filled up by your game faster than the buffers can be 'flushed' to disk. When this happens, the write-to-file functions are forced to wait for the low-level disk write to finish.

On desktop PCs, the buffers involved are HUUUUUUUGE, so you almost never see your file I/O block until you start getting into hundreds of megabytes worth of data. Typically, saved games will not be this large.

However, resource-limited devices like smartphones or old consoles (PS2 and Wii generation) don't have NEARLY as much spare RAM to use for buffering, so their buffers fill up before the game can write all of the data to disk, and suffer from the blocking I/O issue.

No matter what your game does, the hardware speed limit will eventually require your ENTIRE game to pause if you try to write too much data at once, because you will run out of buffer space.

If a game does not have room to make at least one full copy of the data they need to write, then they must pause the game. If they can make one full copy, then the gameplay is not required to pause. Edited by Nypyren

Share this post


Link to post
Share on other sites

 


The API and OS will buffer writes for you, but eventually those buffers will be filled up by your game faster than the buffers can be 'flushed' to disk. When this happens, the write-to-file functions are forced to wait for the low-level disk write to finish.

On desktop PCs, the buffers involved are HUUUUUUUGE, so you almost never see your file I/O block until you start getting into hundreds of megabytes worth of data. Typically, saved games will not be this large.

However, resource-limited devices like smartphones or old consoles (PS2 and Wii generation) don't have NEARLY as much spare RAM to use for buffering, so their buffers fill up before the game can write all of the data to disk, and suffer from the blocking I/O issue.

No matter what your game does, the hardware speed limit will eventually require your ENTIRE game to pause if you try to write too much data at once, because you will run out of buffer space.

If a game does not have room to make at least one full copy of the data they need to write, then they must pause the game. If they can make one full copy, then the gameplay is not required to pause.

 

I see. So I have to pause the game to avoid running out of buffer space or memory. Thanks!

Share this post


Link to post
Share on other sites

 

 


The API and OS will buffer writes for you, but eventually those buffers will be filled up by your game faster than the buffers can be 'flushed' to disk. When this happens, the write-to-file functions are forced to wait for the low-level disk write to finish.

On desktop PCs, the buffers involved are HUUUUUUUGE, so you almost never see your file I/O block until you start getting into hundreds of megabytes worth of data. Typically, saved games will not be this large.

However, resource-limited devices like smartphones or old consoles (PS2 and Wii generation) don't have NEARLY as much spare RAM to use for buffering, so their buffers fill up before the game can write all of the data to disk, and suffer from the blocking I/O issue.

No matter what your game does, the hardware speed limit will eventually require your ENTIRE game to pause if you try to write too much data at once, because you will run out of buffer space.

If a game does not have room to make at least one full copy of the data they need to write, then they must pause the game. If they can make one full copy, then the gameplay is not required to pause.

 

I see. So I have to pause the game to avoid running out of buffer space or memory. Thanks!

 

Not 100% of the time every game is designed different and the saving process can be designed in many different ways. The game doesn't always need to pause.

Share this post


Link to post
Share on other sites


I see. So I have to pause the game to avoid running out of buffer space or memory. Thanks!

 

Pausing the game generally freezes the state of the game: i.e. none of the important data/objects are being modified. This allows the code to take that "frozen game" data and convert it into a format suitable for saving to disk.

 

Saving to disk is relatively slow, just as a fact of hardware. So if this is done on the same thread as the main game loop, then the game will be frozen while this happens. An alternative (if there is enough memory) is to save it to a section of memory, then let the game continue. Then another background thread could copy that section of memory to disk and not require the game to be paused.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!